0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:11:59 +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 <algorithm>
#include <array>
#include <set>
@ -11,7 +12,7 @@ const int N = 10,
int n, ans;
std::array<int, M> a[N];
std::set<std::array<int, M>> set_pre;
std::set<std::array<int, M>> set;
int main() {
std::ios::sync_with_stdio(false);
@ -56,20 +57,16 @@ int main() {
}
if (i == 1) {
ans = set_now.size();
set_pre = set_now;
set = set_now;
} else {
std::set<std::array<int, M>> set;
std::set<std::array<int, M>> set_tmp;
for (auto o : set_pre) {
if (set_now.count(o)) {
set.emplace(o);
}
}
std::set_intersection(set.begin(), set.end(), set_now.begin(), set_now.end(), std::inserter(set_tmp, set_tmp.begin()));
ans = set.size();
set_pre = set;
set = set_tmp;
}
ans = set.size();
}
cout << ans << endl;