Submission #24319

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
243192017-06-04 21:10:03BruteforcemanCop and Robber (BOI14_coprobber)C++11
100 / 100
815 ms7768 KiB
#include "coprobber.h"
#include <queue>
using namespace std;
struct data{
int x,y,z;
}t;
queue<data> q;
int a[510][510][2],nx[510][510],p;
int start(int N, bool A[MAX_N][MAX_N]){
int i,j,cnt;
for(i=0;i<N;++i){
cnt=0;
for(j=0;j<N;++j)if(A[i][j])++cnt;
for(j=0;j<N;++j)if(i!=j)a[j][i][0]=1,a[j][i][1]=cnt;
q.push({i,i,0}),q.push({i,i,1});
}
while(!q.empty()){
t=q.front();
q.pop();
if(t.z){
for(i=0;i<N;++i)if((t.x==i||A[t.x][i])&&a[i][t.y][0]){
--a[i][t.y][0];
if(!a[i][t.y][0])q.push({i,t.y,0}),nx[i][t.y]=t.x;
}
}
else{
for(i=0;i<N;++i)if(A[t.y][i]&&a[t.x][i][1]){
--a[t.x][i][1];
if(!a[t.x][i][1])q.push({t.x,i,1});
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...