Submission #725214

#TimeUsernameProblemLanguageResultExecution timeMemory
725214SanguineChameleonGame (APIO22_game)C++17
60 / 100
4042 ms21212 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int maxN = 3e5 + 20; int max_in[maxN]; vector<int> adj[maxN]; int n, k; void init(int _n, int _k) { n = _n; k = _k; for (int i = 0; i < k; i++) { max_in[i] = i - 1; } for (int i = k; i < n; i++) { max_in[i] = -1; } } void dfs(int u) { for (auto v: adj[u]) { if (max_in[u] > max_in[v]) { max_in[v] = max_in[u]; dfs(v); } } } int add_teleporter(int u, int v) { int cur = max(max_in[u], (u < k ? u : -1)); if (cur > max_in[v]) { max_in[v] = cur; dfs(v); } adj[u].push_back(v); for (int i = 0; i < k; i++) { if (max_in[i] >= i) { 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...