Submission #1026310

#TimeUsernameProblemLanguageResultExecution timeMemory
1026310TurkhuuSeptember (APIO24_september)C++17
45 / 100
86 ms9800 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; using ll = long long; int solve(int N, int M, vector<int> P, vector<vector<int>> S) { vector<int> pos(N), mx(N); for (int i = 0; i < N - 1; i++) { pos[S[0][i]] = mx[S[0][i]] = i; } for (int i = N - 1; i; i--) { mx[P[i]] = max(mx[P[i]], pos[i]); } int ans = 0; for (int i = 0, j = -1; i < N - 1; i++) { if ((j = max(j, mx[S[0][i]])) == i) ans++, j = -1; } 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...