Submission #235607

#TimeUsernameProblemLanguageResultExecution timeMemory
235607mehrdad_sohrabiCop and Robber (BOI14_coprobber)C++14
100 / 100
397 ms8568 KiB
#include <bits/stdc++.h> #include "coprobber.h" typedef int ll; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second #define endl '\n' //#define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define kill(x) return cout<<x<<'\n', 0; using namespace std; const int N=MAX_N; ll C,win[N][N][2],deg[N],d[N][N],p[N][N]; queue <pair <pii,bool> > q; int start(ll n,bool A[N][N]){ for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ deg[i]+=A[i][j]; } } for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ d[i][j]=deg[j]; } } for (int i=0;i<n;i++){ win[i][i][0]=1; p[i][i]=i; q.push({{i,i},0}); q.push({{i,i},1}); win[i][i][1]=1; } while(q.size()){ ll c=q.front().F.F,r=q.front().F.S,b=q.front().S; q.pop(); if (b){ for (int i=0;i<n;i++){ if (A[r][i]){ d[c][i]--; if (d[c][i]==0 && win[c][i][0]==0){ win[c][i][0]=1; q.push({{c,i},0}); } } } } else{ for (int i=0;i<n;i++){ if (i==c || A[c][i]){ if (win[i][r][1]==0){ win[i][r][1]=1; p[i][r]=c; q.push({{i,r},1}); } } } } } for (int i=0;i<n;i++){ ll p1=0; for (int j=0;j<n;j++) if (win[i][j][1]==0) p1=1; if (!p1) return C=i; } return -1; } int nextMove(int R) { return C = p[C][R]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...