제출 #1009299

#제출 시각아이디문제언어결과실행 시간메모리
1009299CSQ31수천개의 섬 (IOI22_islands)C++17
10.85 / 100
44 ms33232 KiB
#include "islands.h" #include<bits/stdc++.h> #include <variant> #include <vector> using namespace std; #define sz(a) (int)(a.size()) #define pb push_back #define fi first #define se second typedef pair<int,int> pii; const int MAXN = 5e5+5; bool dead[MAXN],mark[MAXN]; int outdeg[MAXN]; vector<pii>g[MAXN],gr[MAXN]; void upd(int v){ while(!g[v].empty() && dead[g[v].back().se])g[v].pop_back(); } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V){ for(int i=0;i<M;i++){ gr[V[i]].pb({U[i],i}); g[U[i]].pb({V[i],i}); outdeg[U[i]]++; } vector<int>del; for(int i=0;i<N;i++){ //cout<<i<<" "<<sz(g[i])<<'\n'; if(g[i].empty()){ del.pb(i); mark[i] = 1; } } int cur = 0; while(true){/* if(mark[cur])return false; while(!del.empty()){ vector<int>tmp; for(int u:del){ //cout<<u<<'\n'; for(pii x:gr[u]){ int v = x.fi; outdeg[v]--; dead[x.se] = 1; if(!outdeg[v]){ tmp.pb(v); mark[v] = 1; } } } del = tmp; } if(mark[cur])return false; upd(cur); if(outdeg[cur] > 1)return true; else{ del.push_back(cur); mark[cur] = 1; upd(cur); cur = g[cur].back().fi; }*/ int cnt = 0; for(pii x:g[cur]){ if(!mark[x.fi])cnt++; } if(cnt > 1)return true; if(cnt == 0)return false; for(pii x:g[cur]){ if(!mark[x.fi]){ mark[cur] = 1; cur = x.fi; break; } } } }
#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...