Submission #250116

#TimeUsernameProblemLanguageResultExecution timeMemory
250116Kevin_Zhang_TWCop and Robber (BOI14_coprobber)C++17
0 / 100
1 ms384 KiB
#include "coprobber.h"
#include <bits/stdc++.h>

using namespace std;
#define MAX_N 500
const int inf = 1e9;

// modify the following functions
// you can define global variables and functions
int dp[MAX_N][MAX_N];
int now, n;
bool con[MAX_N][MAX_N];
int start(int n, bool A[MAX_N][MAX_N]) {

	for (int i = 0;i < n;++i)
		for (int j = 0;j < n;++j)
			dp[i][j] = A[i][j] ? 1 : inf, con[i][j] = A[i][j], dp[i][i] = 0;
//	for (int i = 0;i < n;++i)
//		for (int j = 0;j < n;++j) if (i != j)
//			assert(A[i][j]);
	for (int a:{1,1,1})
	for (int k = 0;k < n;++k)
		for (int i = 0;i < n;++i)
			for (int j = 0;j < n;++j)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

	return 0;
//	int res = 0;
//	for (int i = 0;i < n;++i)
//		if (dp[i][i] <= n)
//			res = max(res, dp[i][i]), cerr << dp[i][i] << '\n';
//	if (res > 4) return -1;
//
//	return 0;

}

 
int nextMove(int R) {
	if (con[now][R] || now == R)
		return now = R;
	int go = now, dis = INT_MAX;
	for (int i = 0;i < n;++i)
		if (con[now][i]) {
			dis = min(dis, dp[i][R]);
			if (dis == dp[i][R])
				go = i;
		}
	return now = go;
} 

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:21:11: warning: unused variable 'a' [-Wunused-variable]
  for (int a:{1,1,1})
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...