Submission #999698

#TimeUsernameProblemLanguageResultExecution timeMemory
999698AMel0nSeptember (APIO24_september)C++17
0 / 100
1 ms600 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<bool>> um(M,vector<bool>(N)); 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; } else if (um[i][P[node]]) { ranges.push_back({P[node],node}); } um[i][node]=true; } } 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...