Submission #413561

# Submission time Handle Problem Language Result Execution time Memory
413561 2021-05-28T22:43:55 Z Blagojce Cop and Robber (BOI14_coprobber) C++11
14 / 100
70 ms 4160 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];

int nxt[mxn][mxn];

int cnt[mxn][mxn];


bool vis[mxn][mxn];


void dfs(int u, int v){
	for(auto e1 : g[v]){
		cnt[u][e1] ++;
		if(cnt[u][e1] == (int)g[e1].size()){
			for(auto e2 : gc[u]){
				if(!vis[e2][e1]){
					vis[e2][e1] = true;
					nxt[e2][e1] = u;
					dfs(e2, e1);
				}
			}
		}
	}

}






bool update_status(int u, int v){
	if(vis[u][v]) return false;
	
	for(auto e1 : gc[u]){
		if(cnt[e1][v] == (int)g[v].size()){
			nxt[u][v] = e1;
			vis[u][v] = 1;
			
			for(auto e2 : g[v]){
				cnt[u][e2] ++;
			}
			
			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]){
				g[i].pb(j);
				gc[i].pb(j);
			}
		}
	}
	
	fr(i, 0, n) vis[i][i] = true;
	fr(i, 0, n) nxt[i][i] = i;
	fr(i, 0, n){
		fr(j, 0, n){
			if(A[i][j]){
				nxt[i][j] = j;
				vis[i][j] = true;
				dfs(i, j);
			}
		}
	}
	
	/*
	
	
	
	fr(i, 0, n){
		fr(j, 0, n){
			if(i == j){
				bit[i][j] = 1;
				nxt[i][j] = j;
			}
			else if(A[i][j]){
				bit[i][j] = 1;
				nxt[i][j] = j;
				for(auto e2 : g[j]){
					cnt[i][e2] ++;
				}
				
				
				//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 &= vis[i][j];
		}
		if(cand){
			cop = i;
			return i;
		}
	}
	return -1;
}
int nextMove(int R)
{	
	cop = nxt[cop][R];
	return cop;
}

# Verdict Execution time Memory 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 56 ms 4160 KB Output is correct
5 Correct 15 ms 1992 KB Output is correct
6 Incorrect 65 ms 3804 KB the situation repeated
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 57 ms 3908 KB Output is correct
4 Correct 70 ms 4044 KB Output is correct
5 Correct 54 ms 3776 KB Output is correct
6 Correct 56 ms 3908 KB Output is correct
# Verdict Execution time Memory 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 Incorrect 1 ms 328 KB Cop cannot catch the robber, but start() did not return -1
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 56 ms 4160 KB Output is correct
5 Correct 15 ms 1992 KB Output is correct
6 Incorrect 65 ms 3804 KB the situation repeated