Submission #118698

# Submission time Handle Problem Language Result Execution time Memory
118698 2019-06-19T11:52:31 Z onjo0127 Cop and Robber (BOI14_coprobber) C++11
0 / 100
261 ms 5864 KB
#include "coprobber.h"
#include <bits/stdc++.h>
using namespace std;
 
int now, n, D[MAX_N][MAX_N][2], deg[MAX_N][MAX_N], W[MAX_N][MAX_N];
bool adj[MAX_N][MAX_N], vs[MAX_N][MAX_N];
 
void go(int c, int r, int t) {
	if(D[c][r][t] == 0) return;
	D[c][r][t] = 0;
	if(t == 0) {
		for(int i=0; i<n; i++) {
			if(adj[r][i] && --deg[c][i] == 0) go(c, i, 1);
		}
	}
	else {
		go(c, r, 0); W[c][r] = c;
		for(int i=0; i<n; i++) {
			if(adj[c][i]) {go(i, r, 0); W[i][r] = c;}
		}
	}
}
 
int start(int N, bool A[MAX_N][MAX_N]) {
	n = N;
	memset(W, -1, sizeof(W));
	for(int i=0; i<n; i++) for(int j=0; j<n; j++) D[i][j][0] = D[i][j][1] = 1;
	for(int i=0; i<n; i++) for(int j=0; j<n; j++) adj[i][j] = A[i][j], deg[0][i] += A[i][j];
	for(int i=1; i<n; i++) for(int j=0; j<n; j++) deg[i][j] = deg[0][j];
    for(int i=0; i<n; i++) deg[i][i] = 0;
	for(int i=0; i<n; i++) {go(i, i, 0); go(i, i, 1);}
	for(int i=0; i<n; i++) {
		bool fl = 1;
		for(int j=0; j<n; j++) if(D[i][j][0] == 1) fl = 0;
		if(fl) return now = i;
	}
	return -1;
}
 
bool chk(int v, int R) {
	for(int i=0; i<n; i++) if(adj[R][i] && vs[v][i]) return 0;
	return 1;
}
 
int nextMove(int R) {
	return now = W[now][R];
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Correct 3 ms 1408 KB Output is correct
3 Correct 3 ms 1408 KB Output is correct
4 Incorrect 261 ms 5864 KB the situation repeated
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1408 KB the situation repeated
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1280 KB Output is correct
2 Correct 3 ms 1380 KB Output is correct
3 Correct 3 ms 1408 KB Output is correct
4 Incorrect 3 ms 1408 KB the situation repeated
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Correct 3 ms 1408 KB Output is correct
3 Correct 3 ms 1408 KB Output is correct
4 Incorrect 261 ms 5864 KB the situation repeated
5 Halted 0 ms 0 KB -