제출 #1079208

#제출 시각아이디문제언어결과실행 시간메모리
1079208NourWael수천개의 섬 (IOI22_islands)C++17
0 / 100
2 ms4444 KiB
#include "islands.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int const mxN = 1e3+5; vector<pair<int,int>> adj[mxN], adj2[mxN]; int n,m, cnt[mxN][mxN]; bool vis[mxN], poss[mxN]; vector<int> from[mxN]; bool flag = 0; vector<int> st, fin; void solve( int i , int p) { int fi=-1,se=-1,th=-1,fo=-1, n1 = 0,n2 = 0; for(auto it:adj[i]) { if(it.first==p) continue; if(fi==-1) { fi = it.second; n1 = it.first; } else if(se==-1) { se = it.second; n2 = it.first; } } for(auto it:adj[n1]) { if(it.first==i) { if(th==-1) th = it.second; else fo = it.second; } } for(auto it:adj[n2]) { if(it.first==i) { if(fo==-1) fo = it.second; } } fin = {fi,th,se,fo,th,fi,fo,se}; } void dfs ( int i ) { for(auto it:adj[i]) { if(vis[it.first]) continue; vis[it.first] = 1; st.push_back(it.second); if(adj[it.first].size()>2) { flag = 1; solve(it.first,i); return; } dfs(it.first); } } variant<bool,vector<int>> find_journey( int N, int M,vector<int> U, vector<int> V) { n = N, m = M; int c = 0, c2 = 0; for(int i=0; i<m; i++) { adj[U[i]].push_back({V[i],i}), adj2[V[i]].push_back({U[i],i}); cnt[U[i]][V[i]]++; if(U[i]==0)c++; if(U[i]==1) c2++; } for(auto it:adj[0]) cout<<it.first<<'\n'; vector<int> v; if(c>=2 && c2>=2) { solve(0,-1); return fin; } 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...