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>
#define pb push_back
using namespace std;
typedef long long ll;
vector<int> nbrs[MAX_N];
bool put[MAX_N][MAX_N]; ///i into j
int curr=0;
int start(int N, bool A[MAX_N][MAX_N]){
for(int i=0; i<N; i++){
for(int j=0; j<N; j++){
if(A[i][j]){
if(!put[j][i]){
nbrs[i].pb(j);
put[j][i]=true;
}
if(!put[i][j]){
nbrs[j].pb(i);
put[i][j]=true;
}
}
}
}
return 0;
}
int dfs(int x, int y, int to){
if(x==to) return 0;
for(auto u: nbrs[x]){
if(u==y) continue;
int nas = dfs(u, x, to);
if(nas!=-1){
return 1+nas;
}
}
return -1;
}
int nextMove(int R){
int dist = dfs(curr, -1, R);
for(auto u: nbrs[curr]){
if(dfs(u, -1, R)<dist){
return curr=u;
}
}
return 0;
}
# | 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... |