Submission #1026311

#TimeUsernameProblemLanguageResultExecution timeMemory
1026311TurkhuuSeptember (APIO24_september)C++17
45 / 100
98 ms3208 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 pos(M, vector<int>(N)); vector mx(M, vector<int>(N)); for (int i = 0; i < M; i++) { for (int j = 0; j < N - 1; j++) { pos[i][S[0][j]] = mx[i][S[0][j]] = j; } } for (int i = 0; i < M; i++) { for (int j = N - 1; j; j--) { mx[i][P[j]] = max(mx[i][P[j]], pos[i][j]); } } int ans = 0; for (int i = 0, j = -1; i < N - 1; i++) { for (int k = 0; k < M; k++) { j = max(j, mx[k][S[0][i]]); } if (j == 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...