Submission #999845

#TimeUsernameProblemLanguageResultExecution timeMemory
999845AMel0nSeptember (APIO24_september)C++17
100 / 100
154 ms13624 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define rep(a) for(int i=0;i<a;++i) #define ll long long #define vi vector<int> #define pi pair<int,int> #define node S[i][j] int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) { // vi CHILDREN(N); // for(int i=1; i<N; ++i) { // CHILDREN[P[i]]++; // } vector<vector<int>> um(M,vector<int>(N,-1)); vector<pi> ranges(N, pi(-1,-1)); rep(M) { for(int j=0; j<N - 1; ++j) { if (ranges[node].first == -1) { ranges[node].first = j; } else if (ranges[node].second == -1) { ranges[node].second = j; } else if (ranges[node].second < j) { ranges[node].second = j; }if (um[i][P[node]] != -1) { ranges.push_back({um[i][P[node]],j}); } um[i][node]=j; } } sort(ranges.begin(), ranges.end()); int res = 0, l = 0, r = 0, i = 0; while (l < N - 1){ while (i < ranges.size() && ranges[i].first <= r){ r = max(r, ranges[i].second); i++; } res++; l = r + 1; r++; } return res; }

Compilation message (stderr)

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