# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398895 | almothana05 | Cop and Robber (BOI14_coprobber) | C++14 | 180 ms | 262148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "coprobber.h"
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int menge = 0 , jet = 0 , r = 0;
int cmp = 0 ;
bool done = 0;
vector<vector<int> >num ;
vector<vector<bool> > a;
vector<int >vis(500+10 , 0), comp;
int dfs(int x , int R){
cmp = 0;
if(x == R){
r = 1;
}
vis[x] = 1;
comp.push_back(x);
for(int i = 0 ; i < num[x].size() ; i++){
if(vis[i] == 0 ){
cmp++;
if( dfs(x , R) == -1){
return -1;
}
}
}
if(cmp == 0 && r == 1 ){
return -1;
}
comp.pop_back();
vis[x] = 0;
}
int start(int N, bool A[MAX_N][MAX_N])
{
for(int i = 0 ;i < N ; i++){
a.push_back(vector<bool>());
num.push_back(vector<int>());
for(int j = 0 ; j < N ; j++){
a[i].push_back(A[i][j]);
if(a[i][j] == 1){
num[i].push_back(j);
}
}
}
menge = N;
return 0;
}
int nextMove(int R)
{
if(R == jet){
return jet;
}
if(num[jet][R] == 1){
return R;
}
else{
if(done == 0){
dfs(jet , R);
reverse(comp.begin() , comp.end());
done = 1;
}
cmp = comp[comp.size() - 1];
comp.pop_back();
return cmp;
}
return jet;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |