제출 #1121434

#제출 시각아이디문제언어결과실행 시간메모리
1121434ezzzay9월 (APIO24_september)C++17
45 / 100
132 ms37564 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back const int MN=1e6+5; vector<int>v[MN]; bool vis[MN]; int par[MN]; int pos[MN]; int mx=-1; void dfs(int a){ vis[a]=1; mx=max(mx,pos[a]); for(auto b:v[a]){ if(vis[b]==1)continue; dfs(b); } } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { mx=0; for(int i=0;i<N;i++){ v[i].clear(); vis[i]=0; } for(int i=1;i<N;i++){ par[i]=F[i]; v[F[i]].pb(i); } int k=0; for(int i=0;i<N-1;i++){ pos[S[0][i]]=i; } int i=0; while(i<N-1){ bool u=0; while(i<=mx){ int a=S[0][i]; if(vis[a]==0){ dfs(a); } i++; u=1; } mx++; k++; } return k; }

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

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:38:11: warning: variable 'u' set but not used [-Wunused-but-set-variable]
   38 |      bool u=0;
      |           ^
#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...