Submission #1235728

#TimeUsernameProblemLanguageResultExecution timeMemory
1235728Ghulam_JunaidThousands Islands (IOI22_islands)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "islands.h" // #include "grader.cpp" using namespace std; const int N = 2e5 + 10; int n, m, vis[N]; vector<int> g[N], V; bool res[N]; vector<int> ans; vector<int> path; void get(int v){ if (ans.size()) return ; if (g[v].size() >= 3 or (v == 0 and g[v].size() >= 2)){ res[0] = 1; int prv = -1; if (path.size()) prv = path.back(); int e1 = -1, e2 = -1; if (prv == -1) for (int e : g[v]){ if (e1 == -1) e1 = e; else e2 = e; } } else{ for (int e : g[v]){ if (e == prv) continue; if (e == (prv ^ 1)) continue; if (e1 == -1) e1 = e; else e2 = e; } } ans = path; ans.push_back(e1); ans.push_back(e1 ^ 1); ans.push_back(e2); ans.push_back(e2 ^ 1); ans.push_back(e1 ^ 1); ans.push_back(e1); ans.push_back(e2 ^ 1); ans.push_back(e2); while (path.size()){ ans.push_back(path.back()); path.pop_back(); } return ; } vis[v] = 1; for (int e : g[v]){ int u = V[e]; if (!vis[u]){ path.push_back(e); if (ans.size()) return ; get(u); if (ans.size()) return ; path.pop_back(); } } } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> vv) { V = vv; n = N, m = M; for (int i = 0; i < m; i ++){ g[U[i]].push_back(i); } get(0); if (!res[0]) return false; else return ans; }

Compilation message (stderr)

islands.cpp: In function 'void get(int)':
islands.cpp:32:26: error: 'prv' was not declared in this scope
   32 |                 if (e == prv) continue;
      |                          ^~~
islands.cpp:33:27: error: 'prv' was not declared in this scope
   33 |                 if (e == (prv ^ 1)) continue;
      |                           ^~~
islands.cpp:34:21: error: 'e1' was not declared in this scope; did you mean 'e'?
   34 |                 if (e1 == -1) e1 = e;
      |                     ^~
      |                     e
islands.cpp:35:22: error: 'e2' was not declared in this scope; did you mean 'e'?
   35 |                 else e2 = e;
      |                      ^~
      |                      e
islands.cpp:40:23: error: 'e1' was not declared in this scope; did you mean 'y1'?
   40 |         ans.push_back(e1);
      |                       ^~
      |                       y1
islands.cpp:42:23: error: 'e2' was not declared in this scope
   42 |         ans.push_back(e2);
      |                       ^~
islands.cpp: At global scope:
islands.cpp:57:5: error: 'vis' does not name a type
   57 |     vis[v] = 1;
      |     ^~~
islands.cpp:58:5: error: expected unqualified-id before 'for'
   58 |     for (int e : g[v]){
      |     ^~~
islands.cpp:68:1: error: expected declaration before '}' token
   68 | }
      | ^