Submission #1003498

#TimeUsernameProblemLanguageResultExecution timeMemory
1003498OtalpGame (APIO22_game)C++17
0 / 100
4 ms9816 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int, int> #define ff first #define ss second vector<int> q[200100], dq[200100]; int n, k; pii dp[200100]; int ok = 1; void init(int N, int K) { n = N; k = K; ok = 1; for(int i=1; i<=n; i++){ q[i].clear(); dq[i].clear(); } for(int i=1; i<=k-1; i++){ q[i].pb(i + 1); dq[i + 1].pb(i); } for(int i=1; i<=k; i++){ dp[i] = {i, i}; } for(int i=k+1; i<=n; i++){ dp[i] = {0, n}; } } void dfsmn(int v, pii x){ if(x.ff < dp[v].ff){ ok = 0; return; } int l=dp[v].ff, r=dp[v].ss; int mid=(l+r)/2; if(l <= x.ff and x.ss < mid){ dp[v] = x; } //if(dp[v].ff == dp[v].ss and v > k){ // ok = 0; //} for(int to: dq[v]){ if(dp[to].ss > x.ss){ dfsmn(to, x); } } } void dfsmx(int v, pii x){ if(x.ss > dp[v].ss){ ok = 0; return; } int l=dp[v].ff, r=dp[v].ss; int mid=(l+r)/2; if(mid <= x.ff and x.ss < r){ dp[v] = x; } //if(dp[v].ff == dp[v].ss and v >= k){ // ok = 0; //} for(int to: dq[v]){ if(dp[to].ff < x.ff){ dfsmn(to, x); } } } int add_teleporter(int u, int v) { u++; v++; //cout<<"____________________\n"; //cout<<u<<' '<<v<<'\n'; //if(u == v){ // if(u < k){ // return 1; // } // return 0; //} q[u].pb(v); dq[v].pb(u); dfsmn(v, dp[v]); dfsmx(u, dp[u]); //for(int i=1; i<=n; i++){ // cout<<dp[i].ff<<' '<<dp[i].ss<<'\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...