Submission #993477

#TimeUsernameProblemLanguageResultExecution timeMemory
993477ramalzaherSeptember (APIO24_september)C++17
100 / 100
165 ms18024 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; vector<int> g[N]; int value[N]; void dfs(int node) { for(int to: g[node]) { dfs(to); value[node] = max(value[node], value[to]); } } int solve(int N, int M, vector<int> F, vector<vector<int>> S) { for(int i = 0; i <= N; i++) { g[i].clear(); value[i] = 0; } for(int i = 1; i < N; i++) { g[F[i]].push_back(i); } for(int i = 0; i < M; i++) { for(int j = 0; j < N - 1; j++) { value[S[i][j]] = max(value[S[i][j]], j + 1); } } dfs(0); vector<int> values; for(int i = 1; i < N; i++) { values.push_back(value[i]); } sort(values.begin(), values.end()); // for(int i: values) { // cout << i << " "; // } // cout << "\n"; int pos = 0; int cnt = 0; for(int i = 1; i < N; i++) { while(pos != values.size() && values[pos] == i) { pos += 1; } if(i == pos) { cnt += 1; } } return cnt; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:42:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   while(pos != values.size() && values[pos] == i) {
      |         ~~~~^~~~~~~~~~~~~~~~
#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...