Submission #854007

# Submission time Handle Problem Language Result Execution time Memory
854007 2023-09-25T19:36:05 Z fabijan_cikac Cop and Robber (BOI14_coprobber) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "coprobber.h"

using namespace std;

#define pb push_back

const int N = 510;

vector<int> v[N];
int best[N][N];

//tmp[b][x][y] - ako se policajac nalazi na poziciji x, pljackas na y te je b na redu moze li policajac uloviti lopova
int tmp[2][N][N], tmp2[2][N][N];
int curr;
int solve(int n, bool a[N][N]){
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j){
			if (a[i][j] == 1) v[i].pb(j);
		}
	}
	for (int i = 0; i < n; ++i){
		tmp[0][i][i] = 1; tmp[1][i][i] = 1;
	}
	
	memset(best, -1, sizeof(best));
	for (int i = 0; i < n + 1; ++i){
		for (int x = 0; x < n; ++x){
			for (int y = 0; y < n; ++y){
				//b = 0
				tmp2[0][x][y] = 0;
				if (x == y) tmp2[0][x][y] = 1;
				tmp2[0][x][y] |= tmp[1][x][y];
				if (tmp[1][x][y] == 1)
					best[x][y] = x;
				for (int z: v[x]){
					tmp2[0][x][y] |= tmp[1][z][y];
					if (tmp[1][z][y] == 1)
						best[x][y] = z;
				}
				//b = 1
				tmp2[1][x][y] = 0;
				if (x == y) tmp2[1][x][y] = 1;
				int cnt = 0;
				for (int z: v[y]) cnt += tmp[0][x][z];
				if (cnt == (int)(v[y].size()))
					tmp2[1][x][y] = 1;
			}
		}
		
		for (int x = 0; x < n; ++x){
			for (int y = 0; y < n; ++y)
				tmp[0][x][y] = tmp2[0][x][y], tmp[1][x][y] = tmp2[1][x][y];
		}
	}
	
	int idx = -1;
	for (int i = 0; i < n; ++i){
		bool B = 1;
		for (int j = 0; j < n; ++j){
			if (tmp[0][i][j] == 0) B = 0;
		}
		if (B) idx = i;
	}
	
	return curr = idx;
}

int nextMove(int R){
	return best[curr][R];
}

/*int main(){
	return 0;
}*/

Compilation message

/usr/bin/ld: /tmp/cc7ePuut.o: in function `main':
grader.cpp:(.text.startup+0x16c): undefined reference to `start(int, bool (*) [500])'
collect2: error: ld returned 1 exit status