0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 19:08:47 +00:00

P9752 [CSP-S 2023] 密码锁

https://www.luogu.com.cn/record/135102084
This commit is contained in:
Baoshuo Ren 2023-11-14 20:21:23 +08:00
parent 866d42f1b3
commit 9e895fc8b4
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -1,4 +1,5 @@
#include <iostream> #include <iostream>
#include <algorithm>
#include <array> #include <array>
#include <set> #include <set>
@ -11,7 +12,7 @@ const int N = 10,
int n, ans; int n, ans;
std::array<int, M> a[N]; std::array<int, M> a[N];
std::set<std::array<int, M>> set_pre; std::set<std::array<int, M>> set;
int main() { int main() {
std::ios::sync_with_stdio(false); std::ios::sync_with_stdio(false);
@ -56,20 +57,16 @@ int main() {
} }
if (i == 1) { if (i == 1) {
ans = set_now.size(); set = set_now;
set_pre = set_now;
} else { } else {
std::set<std::array<int, M>> set; std::set<std::array<int, M>> set_tmp;
for (auto o : set_pre) { std::set_intersection(set.begin(), set.end(), set_now.begin(), set_now.end(), std::inserter(set_tmp, set_tmp.begin()));
if (set_now.count(o)) {
set.emplace(o);
}
}
ans = set.size(); set = set_tmp;
set_pre = set;
} }
ans = set.size();
} }
cout << ans << endl; cout << ans << endl;