Submission #1092369

#TimeUsernameProblemLanguageResultExecution timeMemory
1092369raphaelpSeptember (APIO24_september)C++17
100 / 100
124 ms15352 KiB
#include <bits/stdc++.h> using namespace std; int solve(int N, int M, vector<int> F, vector<vector<int>> S) { vector<int> inv(N); vector<vector<int>> AR(N); for (int i = 0; i < N - 1; i++) { AR[F[i + 1]].push_back(i + 1); for (int j = 0; j < M; j++) { inv[S[j][i]] = max(inv[S[j][i]], i); } } int ans = 0, next = 0; for (int i = 0; i < N - 1; i++) { int x = S[0][i]; next = max(next, inv[x]); for (int j = 0; j < AR[x].size(); j++) { next = max(next, inv[AR[x][j]]); } if (next == i) ans++; } return ans; } /*int main() { int N, M; cin >> N >> M; vector<int> p(N); vector<vector<int>> S(M, vector<int>(N - 1)); for (int i = 0; i < N; i++) cin >> p[i]; for (int i = 0; i < M; i++) { for (int j = 0; j < N - 1; j++) { cin >> S[i][j]; } } cout << solve(N, M, p, S); }*/

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int j = 0; j < AR[x].size(); j++)
      |                         ~~^~~~~~~~~~~~~~
#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...