제출 #1061951

#제출 시각아이디문제언어결과실행 시간메모리
1061951AdamGS수천개의 섬 (IOI22_islands)C++17
11.90 / 100
32 ms13148 KiB
#include "islands.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=1e5+7; vector<int>V[LIM], S[LIM]; int deg[LIM], odw[LIM], n, m; variant<bool,vector<int>>find_journey(int _n, int _m, vector<int>_u, vector<int>_v) { n=_n; m=_m; rep(i, m) { V[_u[i]].pb(_v[i]); S[_v[i]].pb(_u[i]); } rep(i, n) deg[i]=V[i].size(); queue<int>q; rep(i, n) if(deg[i]==0) { odw[i]=1; q.push(i); } int akt=0; while(true) { if(deg[akt]<1 || odw[akt]) return false; if(deg[akt]==1) { odw[akt]=1; int p=-1; for(auto i : V[akt]) if(!odw[i]) p=i; if(p==-1) return false; for(auto i : S[akt]) { --deg[i]; if(deg[i]<=1 && !odw[i]) { odw[i]=1; q.push(i); } } akt=p; continue; } if(q.empty()) break; int p=q.front(); q.pop(); for(auto i : S[p]) { --deg[i]; if(deg[i]<=1 && !odw[i]) { odw[i]=1; q.push(i); } } } return true; }
#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...