Submission #787589

#TimeUsernameProblemLanguageResultExecution timeMemory
787589thimote75Thousands Islands (IOI22_islands)C++17
35 / 100
157 ms38060 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; using idata = vector<int>; using igrid = vector<idata>; using graph = vector<vector<pair<pair<int, bool>, int>>>; using bdata = vector<bool>; using bgrid = vector<bdata>; graph roads; bgrid visited; bgrid visiting; bdata used; idata path; bool dfs (int node, int type, int last) { if (visited[node][type] && !visiting[node][type]) return false; if (visiting[node][type]) { if (type == 1) return true; type ++; if (visited[node][type]) return false; } visiting[node][type] = true; visited [node][type] = true; for (const auto &road : roads[node]) { int id = road.first.first; int next = road.second; if (used[id] != road.first.second || last == id) continue ; used[id] = !road.first.second; if (dfs(next, type, id)) return true; used[id] = road.first.second; } visiting[node][type] = false; return false; } std::variant<bool, idata> find_journey( int N, int M, idata U, idata V) { roads.resize(N); visited.resize(N, bdata(2)); visiting.resize(N, bdata(2)); used.resize(M); bool st3 = M % 2 == 0; for (int i = 0; i < M; i ++) { roads[U[i]].push_back({ {i, false}, V[i] }); roads[V[i]].push_back({ {i, true }, U[i] }); } if (!dfs(0, 0, -1)) return false; return true; }

Compilation message (stderr)

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, idata, idata)':
islands.cpp:51:8: warning: unused variable 'st3' [-Wunused-variable]
   51 |   bool st3 = M % 2 == 0;
      |        ^~~
#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...