# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
256943 | MKopchev | 경찰관과 강도 (BOI14_coprobber) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "coprobber.h"
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e2+42;
void force_win(int c,int r);
void force_loss(int c,int r);
int in[nmax][nmax];
int parent[nmax][nmax];
bool is_won[nmax][nmax],is_lost[nmax][nmax];
int n;
void force_win(int c,int r)
{
if(is_won[c][r])return;
is_won[c][r]=1;
for(int r_prv=0;r_prv<n;r_prv++)
{
in[c][r_prv]--;
if(in[c][r_prv]==0)force_loss(c,r_prv);
}
}
void force_loss(int c,int r)
{
if(is_lost[c][r])return;
is_lost[c][r]=1;
for(int c_prv=0;c_prv<n;c_prv++)
if(is_won[c_prv][r]==0)
{
parent[c_prv][r]=c;
force_win(c_prv,r);
}
}
int adj[nmax];
int me;
int start(int N, bool A[nmax][nmax])
{
n=N;
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
if(A[i][j]==1)adj[i]++;
for(int c=0;c<n;c++)
for(int r=0;r<n;r++)
in[c][r]=adj[r];
for(int i=0;i<N;i++)
force_win(i,i);
for(int i=0;i<N;i++)
force_loss(i,i);
for(int c=0;c<N;c++)
{
bool win=1;
for(int r=0;r<N;r++)
if(is_won[c][r]==0)win=0;
if(win)
{
me=c;
return c;
}
}
return -1;
}
int nextMove(int r)
{
me=parent[me][r];
return me;
}
/*
int main()
{
int N=4;
bool A[nmax][nmax]={{0, 1, 1, 1}, {1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}};
cout<<start(N,A)<<endl;
cout<<nextMove(2)<<endl;
cout<<nextMove(0)<<endl;
return 0;
}
*/