제출 #798922

#제출 시각아이디문제언어결과실행 시간메모리
798922Trisanu_Das게임 (APIO22_game)C++17
100 / 100
1648 ms55936 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; const int N=300050; int n,k,l[N],r[N]; vector<int> adj[N],radj[N]; void init(int nn, int kk) { n=nn; k=kk; for (int i=0;i<=k;i++) l[i]=i,r[i]=i+1; for (int i=k+1;i<=n;i++) l[i]=0,r[i]=k+1; for (int i=0;i<=n;i++) adj[i].clear(),radj[i].clear(); } bool addedge(int u,int v){ if (r[u]<=l[v]) return 0; if (l[u]>=r[v]) return 1; if (l[u]==l[v]&&r[u]==r[v]) return 0; if (r[v]<=(l[u]+r[u])/2){ r[u]=(l[u]+r[u])/2; for (int i:radj[u]) if (addedge(i,u)) return 1; for (int i:adj[u]) if (addedge(u,i)) return 1; }else if (l[u]>=(l[v]+r[v])/2){ l[v]=(l[v]+r[v])/2; for (int i:adj[v]) if (addedge(v,i)) return 1; for (int i:radj[v]) if (addedge(i,v)) return 1; } return 0; } int add_teleporter(int u, int v) { u++; if (v>=k) v++; adj[u].push_back(v); radj[v].push_back(u); return addedge(u,v); }
#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...