Submission #982766

#TimeUsernameProblemLanguageResultExecution timeMemory
982766alo_54Game (APIO22_game)C++17
0 / 100
0 ms344 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; struct Nodo { vector <int> ady; bool special = false; }; vector <Nodo> g; vector <bool> vis; bool acPos = false; int dfs(int node, bool isSpecial) { //cout<<"call "<<node<<endl; vis[node] = true; if (g[node].special) { isSpecial = true; } int resp = 0; for (auto i : g[node].ady) { //cout<<"check "<<i<<endl; if (!vis[i]) { return dfs(i, isSpecial); }else { if (isSpecial) { resp = 1; } } } return resp; } void init(int n, int k) { vis.resize(n); g.resize(n); for (int i = 0; i < n; i++) { g[i].special = false; } for (int i = 0; i < k; i++) { g[i].special = true; if (i != k - 1) { g[i].ady.push_back(i + 1); } } } int add_teleporter(int u, int v) { fill(vis.begin(), vis.end(), false); g[u].ady.push_back(v); //cout<<"."<<g[u].ady.back()<<endl; int resp = 0; resp = dfs(u, false); if (resp == true) { acPos = true; } if (acPos) { resp = true; } return resp; }
#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...