Submission #985299

#TimeUsernameProblemLanguageResultExecution timeMemory
985299ph0enlxGame (APIO22_game)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int N = 3e5+10; vector<set<int>> g(N); int ng, kg; void dfs(int ver, int par, bool &exist, vector<bool> &vis, int ret) { vis[ver] = true; for(int child : g[ver]) { if(vis[child]) { if(child==ret) { exist = true; return; } continue; } dfs(child, ver, exist, vis, ret); } } void init(int n, int k) { ng = n, kg = k; for(int i=0; i<k-1; i++) { g[i].insert(i+1); } } int add_teleporter(int u, int v) { if(u==v && u<k) return 1; g[u].insert(v); vector<bool> vis(ng); bool exist=false; for(int i=0; i<kg; i++) { if(vis[i]) continue; dfs(i, i, exist, vis, i); if(exist) return 1; } return 0; }

Compilation message (stderr)

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:36:18: error: 'k' was not declared in this scope
   36 |     if(u==v && u<k) return 1;
      |                  ^