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 <bits/stdc++.h>
#include "speedrun.h"
#define N 1005
using namespace std;
vector<int> adj[N];
bool sub[N];
void init(int v,int num1,int num2){
for(int i = 0;i<10;i++){
setHint(v,i+1,!!(num1 & (1<<(9-i))));
}
for(int i = 0;i<10;i++){
setHint(v,i+11,!!(num2 & (1<<(9-i))));
}
}
void dfs(int v,int par,int num2){
int num1 = 0;
for(auto u:adj[v]){
if(u == par)continue;
if(num1 == 0)num1 = u;
}
int c = par;
for(int i = adj[v].size()-1;i>=0;i--){
if(adj[v][i] == par)continue;
dfs(adj[v][i],v,c);
c = adj[v][i];
}
if(num1 == 0)num1 = par;
init(v,num1,num2);
}
void assignHints(int subtask, int n, int A[], int B[]) {
setHintLen(20);
for(int i = 1;i<n;i++){
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(1,0,0);
}
int get(int x){
int ret = 0;
for(int i = 0;i<10;i++){
ret += getHint(i + 1 + 10 * (x-1)) * (1<<(9-i));
}
return ret;
}
void go(int v){
if(sub[v]){
return;
}
sub[v] = 1;
int now = get(1);
while(now && goTo(now)){
adj[v].push_back(now);
now = get(2);
goTo(v);
}
// cout << v << endl;
// for(auto u:adj[v]){
// cout << u << " ";
// }
// cout << endl;
for(int i = 0;i<adj[v].size();i++){
if(i)goTo(v);
if(adj[v][i] == 0)return;
goTo(adj[v][i]);
go(adj[v][i]);
}
}
void speedrun(int subtask, int n, int start) {
for(int i = 1;i<=n;i++){
adj[i].clear();
}
if(n == 1)return;
go(start);
}
Compilation message (stderr)
speedrun.cpp: In function 'void go(int)':
speedrun.cpp:61:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i = 0;i<adj[v].size();i++){
| ~^~~~~~~~~~~~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |