제출 #1003161

#제출 시각아이디문제언어결과실행 시간메모리
1003161Otalp게임 (APIO22_game)C++17
2 / 100
6 ms9816 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define pb push_back vector<int> q[200100], dq[200100]; int n, k; int mn[200100]; int mx[200100]; int ok = 1; void init(int N, int K) { n = N; k = K; ok = 1; 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); } for(int i=0; i<k; i++){ mn[i] = i + 1; mx[i] = i; } for(int i=k; i<n; i++){ mn[i] = 1e9; mx[i] = -1; } } void dfsmn(int v, int x){ mn[v] = x; if(mn[v] <= mx[v] and mx[v] < k) ok = 0; for(int to: dq[v]){ if(mn[to] > x){ dfsmn(to, x); } } } void dfsmx(int v, int x){ mx[v] = x; if(mn[v] <= mx[v] and mx[v] < k) ok = 0; for(int to: q[v]){ if(mx[to] < x){ dfsmx(to, x); } } } int add_teleporter(int u, int v) { //cout<<"______________________\n"; //cout<<u<<' '<<v<<'\n'; q[u].pb(v); dq[v].pb(u); if(v < k) mn[u] = min(v, mn[u]); if(u < k) mx[v] = max(u, mx[v]); dfsmn(v, mn[v]); dfsmx(u, mx[u]); //for(int i=0; i<n; i++){ // cout<<mn[i]<<' '<<mx[i]<<'\n'; //} return !ok; }
#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...