제출 #103452

#제출 시각아이디문제언어결과실행 시간메모리
103452wilwxk경찰관과 강도 (BOI14_coprobber)C++11
16 / 100
50 ms3832 KiB
#include "coprobber.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN=505;
int gg[MAXN][MAXN];
vector<int> g[MAXN];
int dist[MAXN][MAXN];
int n, cur;

void bfs(int ori) {
	queue<int> qu; qu.push(ori);
	dist[ori][ori]=0;

	while(qu.size()) {
		int cur=qu.front(); qu.pop();
		for(auto viz : g[cur]) {
			if(dist[ori][viz]!=-1) continue;
			qu.push(viz);
			dist[ori][viz]=dist[ori][cur]+1;
		}
	}
}

int start(int N, bool V[MAX_N][MAX_N])
{
	n=N;
	for(int i=0; i<n; i++) {
		for(int j=0; j<n; j++) {
			gg[i][j]=V[i][j];
			if(gg[i][j]) g[i].push_back(j);
		}
	}
	memset(dist, -1, sizeof(dist));
	for(int i=0; i<n; i++) bfs(i);

	
	cur=0;
    return 0;
}

int nextMove(int R)
{
	int melhor=cur;
	for(auto viz : g[cur]) {
		if(dist[viz][R]<=dist[melhor][R]) melhor=viz;
	}
	cur=melhor;
    return melhor;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...