diff --git a/Luogu/P9752/P9752.cpp b/Luogu/P9752/P9752.cpp index 70dfb964..1c1d536e 100644 --- a/Luogu/P9752/P9752.cpp +++ b/Luogu/P9752/P9752.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -11,7 +12,7 @@ const int N = 10, int n, ans; std::array a[N]; -std::set> set_pre; +std::set> 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> set; + std::set> 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;