제출 #674070

#제출 시각아이디문제언어결과실행 시간메모리
674070US3RN4M3수천개의 섬 (IOI22_islands)C++17
0 / 100
5 ms9684 KiB
#include"islands.h" #include<vector> #include<algorithm> #include<iostream> using namespace std; using ll = long long; const int mx = 200005; vector<pair<int, int>> fwd[mx]; vector<pair<int, int>> bck[mx]; int vis[mx]; bool is_cycle[mx]; int N; int bit; bool toggle; bool has_cycle(int cur) { vis[cur] = 1; for(auto [nxt, id] : fwd[cur]) { if(nxt == 0) { if(toggle) { if((id >> bit) & 1) continue; } else { if(!((id >> bit) & 1)) continue; } } if(vis[nxt] == 0) { if(has_cycle(nxt)) return true; } else if(vis[nxt] == 1) { return true; } } vis[cur] = 2; return false; } std::variant<bool, std::vector<int>> find_journey(int _N, int M, std::vector<int> U, std::vector<int> V) { N = _N; return false; for(int i = 0; i < N; i++) { fwd[i].clear(); bck[i].clear(); vis[i] = 0; } for(int i = 0; i < M; i++) { fwd[U[i]].push_back({V[i], i}); bck[V[i]].push_back({U[i], i}); } for(bit = 0; bit < 20; bit++) { for(int i = 0; i < N; i++) vis[i] = 0; toggle = false; if(!has_cycle(0)) continue; for(int i = 0; i < N; i++) vis[i] = 0; toggle = true; if(!has_cycle(0)) continue; return vector<int>(1, 2); } return false; }
#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...