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<bits/stdc++.h>
using namespace std;
vector<vector<int>> ch;
bool B[MAX_N][MAX_N];
int N;
void dfs(int u, int a){
for(int i = 0; i<N; i++){
if(i!=a){
if(B[u][i]){
ch[u].push_back(i);
dfs(i, u);
}
}
}
}
int cop_pos= 0;
int start(int _N, bool A[MAX_N][MAX_N])
{
N= _N;
ch.resize(N);
for(int i = 0; i<MAX_N; i++){
for(int j = 0; j<MAX_N; j++){
B[i][j] = A[i][j];
}
}
dfs(0, -1);
return 0;
}
int find_ch(int u, int target){
if(u == target){
return target;
}
else{
for(auto e: ch[u]){
int i =find_ch(e, target);
if(i!=-1){
return e;
}
}
}
return -1;
}
int nextMove(int R)
{
cop_pos = find_ch(cop_pos, R);
return cop_pos;
}
# | 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... |