Submission #1074346

#TimeUsernameProblemLanguageResultExecution timeMemory
1074346fv3Thousands Islands (IOI22_islands)C++17
9.10 / 100
32 ms6740 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; vector<vector<pair<int, int>>> adj; vector<int> res; bool ok; void DFS(int index, int last) { if (adj[index].size() > 2) { ok = true; return; } for (auto node : adj[index]) { if (node.first == last) continue; res.push_back(node.second); DFS(node.first, index); break; } } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { adj = vector<vector<pair<int, int>>>(N); res = vector<int>(); for (int i = 0; i < M; i++) { adj[U[i]].push_back({V[i], i}); } if (adj[0].size() > 1) { int s_out = adj[0][0].second; int s_in = s_out^1; int e_out = adj[0][1].second; int e_in = e_out^1; return vector<int>({s_out, s_in, e_out, e_in, s_in, s_out, e_in, e_out}); } ok = false; DFS(0, -1); if (ok) return vector<int>({99}); 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...