Submission #730394

#TimeUsernameProblemLanguageResultExecution timeMemory
730394caganyanmazThousands Islands (IOI22_islands)C++17
0 / 100
36 ms3104 KiB
#include <bits/stdc++.h> #define pb push_back #define pp pop_back using namespace std; vector<int> path; vector<bool> visited; vector<vector<int>> g; vector<array<int, 2>> edges; vector<int> double_links; vector<int> result; bool dfs(int node) { if (visited[node] || double_links[node] != -1) return true; visited[node] = true; for (int edge : g[node]) { path.pb(edge); if(dfs(edges[edge][1])) return true; } path.pp(); return false; } vector<int> create_double_links(vector<array<int, 2>> edges, int n, int m) { sort(edges.begin(), edges.end()); vector<int> double_links(n, -1); for (int i = 0; i < m-1; i++) if (edges[i] == edges[i+1]) for (int i = 0; i < 2; i++) double_links[edges[i][i]] = edges[i][i^1]; return double_links; } variant<bool, vector<int>> find_journey(int n, int m, vector<int> u, vector<int> v) { if (n > 2) return true; result.clear(); path.clear(); visited = vector<bool>(n, false); edges = vector<array<int, 2>>(m); for (int i = 0; i < m; i++) cin >> edges[i][0] >> edges[i][1]; double_links = create_double_links(edges, n, m); g = vector<vector<int>>(n); for (int i = 0; i < m; i++) g[edges[i][0]].pb(i); if(dfs(0)) return result; 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...