답안 #38539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38539 2018-01-04T11:51:17 Z Waschbar 경찰관과 강도 (BOI14_coprobber) C++14
16 / 100
230 ms 262144 KB
#include <bits/stdc++.h>
#include "coprobber.h"
//using namespace std;

//const int MAX_N = 15;
int n, s, timer;
int p[1000], tin[1000], tout[1000];
bool ind;
bool g[1000][1000];
bool used[1000];

void DFS(int f, int pr) {
		p[f] = pr;
		tin[f] = ++timer;
		used[f] = 1;
		
		for(int i = 0; i < n; i++) {
			if(!g[f][i] || i == pr) continue;
			if(used[i]) ind = 1;
			DFS(i,f);
		}	
		
		tout[f] = timer;
}

bool upper(int x, int y) {
	//cout << x << " - " << tin[x] << " " << tout[x] << " | " << y << " - " << tin[y] << " " << tout[y] << endl;
	return ((tin[x] <= tin[y]) && (tout[x] >= tout[y]));
}

int start(int N, bool A[MAX_N][MAX_N]) {
    n = N; s = 0;
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
    	g[i][j] = A[i][j];
    	
    DFS(0, -1);
    
    if(ind) return -1;
	return 0;
}

int nextMove(int R) {
    for(int i = 0; i < n; i++) {
    	//cout << s << " " << i << " " << g[s][i] << endl;
    	if(!g[s][i] || i == p[s]) continue;
    	if(upper(i,R)) {s = i; return i;}
	}
	return -1;
}
/*
bool v[MAX_N][MAX_N];

int main() {
	
	int nn;
	cin >> nn;
	
	for(int i = 1; i < nn; i++) {
		int x, y;
		cin >> x >> y;
		v[x][y] = v[y][x] = 1;
	}
	
	cout << ":: " << start(nn,v) << endl;
	
	while(true){
		int x;
		cin >> x;
		cout <<":: " << nextMove(x) << endl;
	}
	
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 42 ms 2300 KB Output is correct
5 Correct 11 ms 1280 KB Output is correct
6 Correct 43 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 224 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Runtime error 228 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 44 ms 2296 KB Output is correct
5 Correct 12 ms 1152 KB Output is correct
6 Correct 44 ms 2084 KB Output is correct
7 Runtime error 230 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Halted 0 ms 0 KB -