답안 #614953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
614953 2022-07-31T05:42:14 Z amunduzbaev 경찰관과 강도 (BOI14_coprobber) C++17
0 / 100
127 ms 5440 KB
#include "coprobber.h"
#include "bits/stdc++.h"
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif
#define ar array

const int M = 505;
int dp[2][M][M], par[M][M];
int d[M][M], s;

int start(int n, bool a[MAX_N][MAX_N]){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				d[j][i] += a[j][k];
			}
		}
	}
	
	queue<ar<int, 3>> q;
	for(int i=0;i<n;i++){
		dp[0][i][i] = 1, dp[1][i][i] = 1;
		q.push({0, i, i});
		q.push({1, i, i});
	}
	
	while(!q.empty()){
		auto [t, u, v] = q.front(); q.pop();
		for(int i=0;i<n;i++){
			if(t){
				d[i][v]--;
				if(a[i][u] && !d[i][v]){
					dp[0][i][v] = 1;
					q.push({0, i, v});
				}
			} else {
				if(a[i][v] && !dp[1][u][i]){
					par[u][i] = v;
					dp[1][u][i] = 1;
					q.push({1, u, i});
				}
			}
		}
	}
	
	s = -1;
	for(int i=0;i<n;i++){
		bool ok = 1;
		for(int j=0;j<n;j++){
			if(!dp[1][j][i]) ok = 0;
		}
		
		if(ok){
			s = i;
			break;
		}
	}
	
	return s;
}

int nextMove(int R){
	s = par[R][s];
	return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 127 ms 5440 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 336 KB Cop can catch the robber, but start() returned -1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 127 ms 5440 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -