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 <vector>
#include <set>
#include <bits/stdc++.h>
using namespace std;
vector<set<int>> kid;
vector<vector<int>> adj;
vector<int> path;
int n,p,par,old=-1;
void calc(int u, int p){
path.push_back(u);
for(auto v:adj[u]){
if(v==p) continue;
calc(v,u);
}
path.pop_back();
for(auto i:path){
kid[i].insert(u);
}
}
int solve(int u, int p, int r) {
for (auto v:adj[u]) {
if (v == p) continue;
printf("fun: %d %d\n",p,r);
if (v == r) return r;
if (kid[v].find(r) != kid[v].end()) return v;
}
}
int start(int N, bool A[MAX_N][MAX_N]){
n=N;
kid.resize(N+2,set<int>());
adj.resize(N+2,vector<int>());
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(A[i][j]){
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
calc(0,-1);
return p=0;
}
int nextMove(int R)
{
printf("%d\n",p);
par = old;
old = p;
p = solve(p,par,R);
printf("%d %d\n",p,R);
return p;
}
Compilation message (stderr)
coprobber.cpp: In function 'int solve(int, int, int)':
coprobber.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
30 | }
| ^
# | 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... |