제출 #797217

#제출 시각아이디문제언어결과실행 시간메모리
797217penguinman수천개의 섬 (IOI22_islands)C++17
0 / 100
1067 ms6416 KiB
#include "islands.h" #include <bits/stdc++.h> #include <variant> using std::cin; using std::cout; using std::endl; using std::vector; using std::string; using ll = int; using vi = vector<ll>; using vii = vector<vi>; using pii = std::pair<ll,ll>; #define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++) #define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++) #define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--) #define all(a) a.begin(),a.end() #define pb emplace_back #define ln "\n" std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) { vii edge(N), index(N); rep(i,0,M){ edge[U[i]].pb(V[i]); index[U[i]].pb(i); } vi ans; bool flag = false; { ll now = 0; while(true){ vi ind, nex; rep(i,0,edge[now].size()){ if(ans.empty() || (ans.back()^1) != index[now][i]){ ind.pb(index[now][i]); nex.pb(edge[now][i]); } } if(ind.size() == 0) break; if(ind.size() == 1){ now = nex[0]; continue; } flag = true; ll len = ans.size(); rep(i,0,2){ ans.pb(ind[i]); ans.pb(ind[i]^1); } rep(i,0,2){ ans.pb(ind[i]^1); ans.pb(ind[i]); } per(i,len-1,0) ans.pb(ans[i]); break; } } if(flag) return ans; else 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...