Submission #1079198

#TimeUsernameProblemLanguageResultExecution timeMemory
1079198NourWaelThousands Islands (IOI22_islands)C++17
0 / 100
2 ms4368 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,n2; 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; 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]]++; } for(auto it:adj[0]) cout<<it.first<<'\n'; vector<int> v; if(adj[0].size()>1) { solve(0,-1); return fin; } else { vis[0] = 1; dfs(0); } if(flag) { vector<int> tot = st; for(auto it:fin) tot.push_back(it); reverse(st.begin(),st.end()); for(auto it:st) tot.push_back(it); return tot; } return false; }

Compilation message (stderr)

islands.cpp: In function 'void solve(int, int)':
islands.cpp:15:35: warning: 'n2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |   int fi=-1,se=-1,th=-1,fo=-1, n1,n2;
      |                                   ^~
islands.cpp:15:32: warning: 'n1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |   int fi=-1,se=-1,th=-1,fo=-1, n1,n2;
      |                                ^~
#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...