Submission #1064522

#TimeUsernameProblemLanguageResultExecution timeMemory
1064522Shadow1September (APIO24_september)C++17
0 / 100
8 ms604 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; #define output_vector(v) for(auto &x : v){cout << x << ' ';}cout << '\n'; #define show(x) cerr << (#x) << " = " << (x) << '\n'; int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { int ans = N; vector<vector<int>> child(N); for(int i=1; i<N; ++i) { child[F[i]].push_back(i); } for(int i=0; i<M; ++i) { int cnt = 0; set<int> cur; vector<set<int>> c(N); for(int j=0; j<N; ++j) { for(auto &k : child[j]) c[j].insert(k); } for(int j=0; j<N; ++j) { int k = S[i][j]; cur.insert(k); while(k > 0 && c[k].empty()) { cur.erase(k); c[F[k]].erase(k); k = F[k]; } cnt += (cur.empty()); } ans = min(ans, cnt); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...