Submission #398944

# Submission time Handle Problem Language Result Execution time Memory
398944 2021-05-04T22:37:48 Z shrimb Cop and Robber (BOI14_coprobber) C++17
0 / 100
165 ms 262148 KB
#include"bits/stdc++.h"
using namespace std;
#define MAX_N 500
vector<int> adj[501];
int cur = 0, nig;

int start(int N, bool A[MAX_N][MAX_N]) {
	for (int i = 0 ; i < N ; i++) {
		for (int j = 0 ; j < N ; j++) {
			if (A[i][j]) adj[i].push_back(j);
		}
	}
	return 0;
}

bool check (int c, int p) {
	bool res = 0;
	for (int i : adj[c]) {
		if (i == nig) return 1;
		res |= check(i, c);
	}
	return res;
}

int nextMove(int R) {
	nig = R;
	for (int i : adj[cur]) {
		if (i == R || check(i, cur)) return i;
	}
}

// don't modify the main function
// int main() {
//     int N;
//     cin >> N;
//     bool A[MAX_N][MAX_N];
//     for (int i = 0; i < N; i++) {
//         for (int j = 0; j < N; j++) {
//             cin >> A[i][j];
//         }
//     }
//     int P = start(N,A);
//     cout << P << endl;
//     int R;
//     cin >> R;
//     while (true) {
//         if (P == R) break;
//         P = nextMove(R);
//         cout << P << endl;
//         if (P == R) break;
//         cin >> R;
//     }
// }

Compilation message

coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Runtime error 161 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 165 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Runtime error 152 ms 262148 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Runtime error 161 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -