Submission #852779

# Submission time Handle Problem Language Result Execution time Memory
852779 2023-09-22T16:47:34 Z drkarlicio2107 Cop and Robber (BOI14_coprobber) C++14
0 / 100
1 ms 6488 KB
#include "coprobber.h"
#include <bits/stdc++.h>
using namespace std;
int kol [510][510][2];
int st [510][510][2];
queue < pair <int, pair <int, int> > > kju;
int mov [510][510];

int curr;
int start (int n, bool l [MAX_N][MAX_N]){
	for (int i=0; i<n; i++){
		for (int j=0; j<n; j++){
			int uk=0;
			for (int k=0; k<n; k++) uk+=l [j][k];
			kol [i][j][0]=1;
			kol [i][j][1]=uk;
			if (i==j){
				kju.push ({0, {i, j}});
				kju.push ({1, {i, j}});
			}
		}
	}
	while (!kju.empty()){
		int m=kju.front().first;
		int a=kju.front().second.first;
		int b=kju.front().second.second;
		//cout << m << " " << a << " " << b << endl;
		st [m][a][b]=1;
		if (m==0){
			for (int i=0; i<n; i++){
				if (!l [i][b]) continue;
				kol [a][i][1]--;
				if (kol [a][i][1]==0){
					kju.push ({1, {a, i}});
				}
			}
		}
		else {
			for (int i=0; i<n; i++){
				if (!l [i][a]) continue;
				kol [i][b][0]--;
				if (kol [i][b][0]==0){
					kju.push ({0, {i, b}});
					mov [i][b]=a;
				}
			}
		}
		kju.pop();
	}
	for (int i=0; i<n; i++){
		int uk=0;
		for (int j=0; j<n; j++) uk+=st [1][i][j];
		if (uk==n) return curr=i;
	}
	return -1;
}
int nextMove (int x){
	return curr=mov [curr][x];
}
/*int a [510][510];
int main(){
	int n; cin >> n; 
	for (int i=0; i<n; i++){
		for (int j=0; j<n; j++) cin >> a [i][j];
	}
	cout << start (n, a) << endl;
	while (true){
		int x; cin >> x;
		if (x==-1) break;
		cout << nextMove (x) << endl;
	}
	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6488 KB Cop can catch the robber, but start() returned -1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB Cop can catch the robber, but start() returned -1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6488 KB Cop can catch the robber, but start() returned -1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6488 KB Cop can catch the robber, but start() returned -1
3 Halted 0 ms 0 KB -