답안 #413550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413550 2021-05-28T22:05:16 Z Blagojce 경찰관과 강도 (BOI14_coprobber) C++11
0 / 100
1500 ms 2736 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
  
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
const ll inf = 1e18;
const int i_inf = 1e9;
const ll mod = 1e9+7;
  
const int mxn = 505;


#include "coprobber.h"



int n;
vector<int> g[mxn];
vector<int> gc[mxn];

bool bad[mxn][mxn];
int nxt[mxn][mxn];



bitset<mxn> adj[mxn];
bitset<mxn> bit[mxn];


bool update_status(int u, int v){
	if(bit[u][v]) return false;
	if(gc[u].size() >= sqrt(n)){
		for(auto e1 : gc[u]){
			bool ok = true;
			for(auto e2 : g[v]){
				ok &= bit[e1][e2];
			}
			if(ok){
				bit[u][v] = 1;
				nxt[u][v] = e1;
			}
		}
	}
	
	else{
		for(auto e1 : gc[u]){
			
			if((bit[e1]&adj[v]) == adj[v]){
				bit[u][v] = 1;
				nxt[u][v] = e1;
				return true;
			}
			
			/*bool ok = true;
			for(auto e2 : g[v]){
				ok &= bad[e1][e2];
			}
			bad[u][v] |= ok;
			if(ok){
				nxt[u][v] = e1;
				return true;
			}*/
		}
	}	
	return false;
}
int cop;

int start(int N, bool A[MAX_N][MAX_N])
{
	n = N;
	fr(i, 0, n){
		gc[i].pb(i);
		fr(j, 0, n){
			if(A[i][j]){
				adj[i][j] = 1;
				g[i].pb(j);
				gc[i].pb(j);
			}
		}
	}
	fr(i, 0, n){
		fr(j, 0, n){
			if(i == j || A[i][j]){
				bit[i][j] = 1;
				nxt[i][j] = j;
				
				//nxt[i][j] = j;
				
				//bad[i][j] = true;
			}
		}
	}
	bool progress = true;
	while(progress){
		progress = false;
		fr(i, 0, n){
			fr(j, 0, n){
				progress |= update_status(i, j);
			}
		}
	}
	fr(i, 0, n){
		bool cand = true;
		fr(j, 0, n){
			cand &= bit[i][j];
		}
		if(cand){
			cop = i;
			return i;
		}
	}
	return -1;
}
int nextMove(int R)
{	
	cop = nxt[cop][R];
	return cop;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Execution timed out 2791 ms 2732 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 421 ms 2588 KB Output is correct
4 Execution timed out 1818 ms 2736 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 4 ms 584 KB Output is correct
11 Correct 19 ms 584 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 3 ms 456 KB Output is correct
14 Correct 15 ms 584 KB Output is correct
15 Correct 2 ms 584 KB Output is correct
16 Correct 3 ms 584 KB Output is correct
17 Incorrect 15 ms 840 KB Cop can catch the robber, but start() returned -1
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Execution timed out 2791 ms 2732 KB Time limit exceeded
5 Halted 0 ms 0 KB -