Submission #1076980

#TimeUsernameProblemLanguageResultExecution timeMemory
1076980mariaclaraThousands Islands (IOI22_islands)C++17
0 / 100
1 ms604 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define pb push_back #define mk make_pair #define fr first #define sc second vector<int> vis, block, at; vector<vector<pii>> edges; vector<int> dfs(int x) { vis[x] = 1; for(auto [viz,ind] : edges[x]) { if(block[viz]) continue; if(vis[viz]) { at.pb(ind); return at; } at.pb(ind); vector<int> v = dfs(viz); if(!v.empty()) return v; } block[x] = 1; return {}; } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { edges.resize(N); vis.resize(N); block.resize(N); for(int i = 0; i < M; i += 2) edges[U[i]].pb({V[i], i}); vector<int> c = dfs(0), ans; if(c.empty()) return false; int x = V[c.back()], m; for(int i = sz(c) - 1; i >= 0; i--) if(U[i] == x) m = i; ans = c; for(int i = m-1; i >= 0; i--) ans.pb(c[i]); for(int i = 0; i < m; i++) ans.pb(c[i] + (i == 0)); for(int i = sz(c) - 1; i >= m; i--) ans.pb(c[i]); for(int i = m-1; i >= 0; i--) ans.pb(c[i] + (i == 0)); }

Compilation message (stderr)

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:42:26: warning: control reaches end of non-void function [-Wreturn-type]
   42 |     vector<int> c = dfs(0), ans;
      |                          ^
#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...