제출 #721963

#제출 시각아이디문제언어결과실행 시간메모리
721963pere_gil수천개의 섬 (IOI22_islands)C++17
0 / 100
34 ms7760 KiB
#include "islands.h" #include "bits/stdc++.h" using namespace std; #define ii pair<int,int> const int MAX_N=1e5+5; vector<ii> adj[MAX_N]; vector<bool> vis(MAX_N,false); vector<int> path,res; int piv=-1; void dfs(int u){ if(piv!=-1) return; vis[u]=true; if(adj[u].size()>=2){ piv=u; int a=adj[u][0].second,b=adj[u][1].second; vector<int> aux={a,a+1,b,b+1,a+1,a,b+1,b}; for(int i: path) res.push_back(i); for(int i: aux) res.push_back(i); for(int i=path.size()-1;i>=0;i--) res.push_back(path[i]); return; } for(auto v: adj[u]){ if(vis[v.first]) continue; path.push_back(v.second); dfs(v.first); path.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+=2) adj[u[i]].push_back({v[i],i}); dfs(0); if(piv==-1) return false; return res; }
#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...