제출 #988971

#제출 시각아이디문제언어결과실행 시간메모리
988971Otalp게임 (APIO22_game)C++17
30 / 100
4011 ms12056 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define pb push_back vector<int> q[200100], dq[200100]; int n, k; void init(int N, int K) { n = N; k = K; for(int i=0; i<n; i++){ q[i].clear(); dq[i].clear(); } for(int i=0; i<k-1; i++){ q[i].pb(i + 1); dq[i + 1].pb(i); } } int dp[200100], us[200100]; void dfs(int v){ us[v] = 1; for(int to: q[v]){ if(!us[to]) dfs(to); dp[v] = min(dp[v], dp[to]); dp[v] = min(dp[v], to); } } int add_teleporter(int u, int v) { for(int i=0; i<n; i++){ us[i] = 0; dp[i] = 1e9; } q[u].pb(v); dq[v].pb(u); for(int i=0; i<n; i++){ if(us[i]) continue; dfs(i); } for(int i=0; i<k; i++){ if(dp[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...