Submission #985259

#TimeUsernameProblemLanguageResultExecution timeMemory
985259ph0enlxGame (APIO22_game)C++17
2 / 100
2 ms7256 KiB
#include<bits/stdc++.h> using namespace std; const int N = 3e5+10; vector<int> g[N]; int ng, kg; void dfs(int ver, int par, bool &exist, vector<bool> &vis) { vis[ver] = true; for(int child : g[ver]) { if(vis[child]) { if(child!=par) { exist = true; return; } continue; } dfs(child, ver, exist, vis); } } void init(int n, int k) { ng = n, kg = k; for(int i=0; i<k-1; i++) { g[i].push_back(i+1); } } int add_teleporter(int u, int v) { if(u>v || u==v) return 1; return 0; if(u==v) return 1; g[u].push_back(v); vector<bool> vis(ng); bool exist=false; for(int i=0; i<kg; i++) { if(vis[i]) continue; dfs(i, i, exist, vis); if(exist) return 1; } return 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...