제출 #1081744

#제출 시각아이디문제언어결과실행 시간메모리
1081744SugarCubes699월 (APIO24_september)C++17
0 / 100
1018 ms3160 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=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; }

컴파일 시 표준 에러 (stderr) 메시지

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:32: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]
   32 |     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...