Submission #854312

#TimeUsernameProblemLanguageResultExecution timeMemory
854312fabijan_cikacCop and Robber (BOI14_coprobber)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back

//T = 0 - policajac na redu
struct state{
	int T, C, R;
};
 
const int N = 500;
 
vector<int> v[N];

int bio[2][N][N];
int cnt[N][N], best[N][N]; int curr;
int start(int n, bool a[N][N]){
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j){
			if (a[i][j]) v[i].pb(j);
		}
	}
	
	queue<state> q;
	for (int i = 0; i < n; ++i){
		q.push({0, i, i}); q.push({1, i, i});
		bio[0][i][i] = 1; bio[1][i][i] = 1;
		dp[0][i][i] = 1; dp[1][i][i] = 1;
	}
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j)
			cnt[i][j] = (int)(v[j].size());
	}
	
	memset(best, -1, sizeof(best));
	while (!q.empty()){
		state X = q.front(); q.pop();
		if (!X.T){
			for (int z: v[X.R]){
				--cnt[X.C][z];
				if (cnt[X.C][z] == 0){
					bio[1][X.C][z] = 1;
					q.push({1, X.C, z});
				}
			}
		}
		else{
			if (!bio[0][X.C][X.R]){
				best[X.C][X.R] = X.C;
				bio[0][X.C][X.R] = 1;
				q.push({0, X.C, X.R});
			}
			for (int z: v[X.C]){
				if (!bio[0][z][X.R]){
					best[z][X.R] = X.C;
					bio[0][z][X.R] = 1;
					q.push({0, z, X.R});
				}
			}
		}
	}
	
	int idx = -1;
	for (int i = 0; i < n; ++i){
		int num = n;
		for (int j = 0; j < n; ++j)
			num -= bio[0][i][j];
		if (num == 0) idx = i;
	}
	
	curr = idx; return idx;
}
 
int nextMove(int R){
	return curr = best[curr][R];
}

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:29:3: error: 'dp' was not declared in this scope
   29 |   dp[0][i][i] = 1; dp[1][i][i] = 1;
      |   ^~