Submission #652960

#TimeUsernameProblemLanguageResultExecution timeMemory
652960aryan12Game (APIO22_game)C++17
60 / 100
4011 ms21908 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; vector<int> g[N]; int max_n, max_k; int aa[N]; bool isCycle = false; void init(int n, int k) { max_n = n, max_k = k; for(int i = 0; i < n; i++) { aa[i] = (i < k) ? i : -1; } } void dfs(int node, int val) { if(aa[node] >= val) { return; } aa[node] = val; for(int to: g[node]) { if(to < max_k) { if(val >= to) { isCycle = true; break; } continue; } dfs(to, val); } } int add_teleporter(int u, int v) { g[u].push_back(v); if((v < max_k && aa[u] >= v) || (u < max_k && v <= u)) { return true; } if(aa[v] < aa[u]) { dfs(v, aa[u]); } return isCycle; }
#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...