Submission #1081752

#TimeUsernameProblemLanguageResultExecution timeMemory
1081752SugarCubes69September (APIO24_september)C++17
100 / 100
199 ms21964 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; int deg[100005]; int fst[100005],lst[100005]; vector<int> adj[100005]; void dfs(int x){ for(int child:adj[x]){ dfs(child); lst[x] = max(lst[x],lst[child]); } } int solve(int n, int m, vector<int> P, vector<vector<int> > a) { for(int i=0;i<n;i++) adj[i].clear(); for(int i=1;i<n;i++) adj[P[i]].push_back(i); fill(fst,fst+n,n); memset(lst,0,sizeof(lst)); for(int i=0;i<m;i++) for(int j=0;j<n-1;j++){ fst[a[i][j]] = min(fst[a[i][j]],j); lst[a[i][j]] = max(lst[a[i][j]],j); } dfs(0); vector<pair<int,int> > intervals; for(int i=1;i<n;i++) intervals.push_back(pair<int,int>(fst[i],lst[i])); sort(intervals.begin(),intervals.end()); int ans = 0; int bak = -1; for(int i=0;i<intervals.size();i++){ if(bak < intervals[i].first){ ans++; } bak = max(bak,intervals[i].second); } return ans; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:33: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]
   33 |     for(int i=0;i<intervals.size();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...