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 "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
void assignHints(int id,int n, int*a, int*b) {
if (id==1) {
setHintLen(n);
for(int i=0;i<n-1;++i) {
int u=a[i],v=b[i];
setHint(u,v,1);
setHint(v,u,1);
}
}
if (id==2) {
setHintLen(20);
vector<int>deg(n+1,0);
for(int i=0;i<n-1;++i) deg[a[i]]++;
for(int i=0;i<n-1;++i) deg[b[i]]++;
int mx=0;
for(int i=1;i<=n;++i) if (deg[i]>deg[mx]) mx=i;
for (int i=1; i<=n; ++i) {
if (i==mx) continue;
for (int j=11; j>0; --j) {
setHint(i,j,!!(mx&(1<<(j-1))));
}
}
}
}
int n;
vector<vector<int>> adj(1e3+1,vector<int>(1e3+1,0));
void dfs(int u, int p) {
for (int j=1; j<=n; ++j) {
adj[u][j]=getHint(j);
}
for (int i=1; i<=n; ++i) {
if (i==p) continue;
if (adj[u][i]) {
goTo(i);
dfs(i,u);
}
}
if (p==-1) return;
goTo(p);
}
void speedrun(int id,int N,int start) {
n=N;
if (id==1) {
dfs(start,-1);
}
}
# | 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... |