Submission #1113556

#TimeUsernameProblemLanguageResultExecution timeMemory
1113556_8_8_Game (APIO22_game)C++17
60 / 100
4011 ms18796 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 3e5 + 12; int n, k, s[N], t[N]; vector<int> g[N], gr[N]; void init(int nn, int kk) { n = nn; k = kk; for(int i = k; i < n; i++) { s[i] = -1, t[i] = k; } for(int i = 0; i < k; ++i) { s[i] = t[i] = i; } } int vis[N], timer; void dfs(int v, int val) { vis[v] = timer; s[v] = max(s[v], val); for(int to:g[v]) if(vis[to] != timer && s[to] < val) { dfs(to, val); } } void dfs1(int v, int val) { t[v] = min(t[v], val); for(int to:gr[v]) if(vis[to] != timer && t[to] > val) { dfs1(to, val); } } bool cyc = 0; int add_teleporter(int u, int v) { if(max(u, v) < k) { if(u >= v) cyc = 1; } if(cyc) return 1; g[u].push_back(v); gr[v].push_back(u); for(int i = k; i < n; i++) { if(s[i] >= t[v]) { s[i] = max(s[i], s[u]); } } timer++; dfs(v, s[u]); timer++; dfs1(u, t[v]); vis[v] = timer; for(int i = k; i < n; i++) { if(s[i] >= t[i]) { cyc = 1; 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...