제출 #982716

#제출 시각아이디문제언어결과실행 시간메모리
982716vjudge1게임 (APIO22_game)C++17
60 / 100
4085 ms27752 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector <ll>; const ll MAXN = 3E5+16; int n, k; vll adj[MAXN]; ll maxK[MAXN]; void init (int n, int k) { ::n = n, ::k = k; fill(maxK, maxK+n+4, -1); for (ll i = 0; i < k; i++) maxK[i] = i; for (ll i = 1; i < k; i++) { adj[i-1].push_back(i); } } ll tvis[MAXN]; ll timer = 1; ll dfs (ll u) { if (tvis[u] == timer) return 0; tvis[u] = timer; for (ll v : adj[u]) { if (v <= maxK[u]) return 1; if (maxK[v] >= maxK[u]) continue; // this pruning is insane (hopefully) maxK[v] = maxK[u]; if (dfs(v)) return 1; } return 0; } int add_teleporter (int u, int v) { adj[u].push_back(v); timer++; return dfs(u); }
#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...