제출 #1006037

#제출 시각아이디문제언어결과실행 시간메모리
1006037amirhoseinfar1385게임 (APIO22_game)C++17
2 / 100
3 ms15192 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; const int maxn=300000+10; int n,k,l[maxn],r[maxn]; vector<int>adj[maxn],revadj[maxn]; void init(int n_, int k_) { n=n_; k=k_; for(int i=1;i<=k;i++){ l[i]=i; r[i]=i+1; } for(int i=k+1;i<=n;i++){ l[i]=-1; r[i]=k+1; } } int calc(int u,int v){ if(u==v){ return 1; } if(r[u]<=l[v]){ return 0; } // cout<<u<<" "<<v<<endl; if(l[u]>=r[v]){ return 1; } if(l[u]<=l[v]&&r[v]>=r[u]){ return 0; } if(r[v]<=(l[u]+r[u])/2){ r[u]=(l[u]+r[u])/2; for(auto x:revadj[u]){ if(calc(x,u)){ return 1; } } for(auto x:adj[u]){ if(calc(u,x)){ return 1; } } } if(l[u]>=(l[v]+r[v])/2){ l[v]=(l[v]+r[v])/2; for(auto x:adj[v]){ if(calc(v,x)){ return 1; } } for(auto x:revadj[v]){ if(calc(x,v)){ return 1; } } } return 0; } int add_teleporter(int u, int v) { u++; v++; adj[u].push_back(v); revadj[v].push_back(u); if(calc(u,v)){ // cout<<"1hey"<<endl; return 1; } //cout<<"0hey"<<endl; 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...