Submission #991336

#TimeUsernameProblemLanguageResultExecution timeMemory
991336SanguineChameleonSeptember (APIO24_september)C++17
100 / 100
95 ms6100 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; int solve(int N, int M, vector<int> F, vector<vector<int>> S) { vector<int> cnt_S(N); vector<int> cnt_ch(N); vector<bool> flag(N); for (int i = 1; i < N; i++) { cnt_ch[F[i]]++; } int cnt_bad = 0; int res = 0; for (int i = 0; i < N - 1; i++) { for (int j = 0; j < M; j++) { int u = S[j][i]; cnt_bad -= (cnt_S[u] != 0 && cnt_S[u] != M); cnt_S[u]++; cnt_bad += (cnt_S[u] != 0 && cnt_S[u] != M); } int u = S[0][i]; cnt_bad -= (flag[F[u]] && cnt_ch[F[u]] > 0); flag[u] = true; cnt_ch[F[u]]--; cnt_bad += (flag[F[u]] && cnt_ch[F[u]] > 0); cnt_bad += (flag[u] && cnt_ch[u] > 0); if (cnt_bad == 0) { res++; } } return res; }
#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...