//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "speedrun.h"
vector<int> adj[1001];
int co=0;
int ind[1001];
int st[1001];
int par[1001];
void dfs(int no,int par2=0){
st[no]=co;
ind[co]=no;
co++;
par[no]=par2;
for(auto j:adj[no]){
if(j!=par2){
dfs(j,no);
}
}
}
void assignHints(int subtask, int n, int aa[], int bb[]) { /* your solution here */
for(int i=1;i<n;i++){
adj[aa[i]].pb(bb[i]);
adj[bb[i]].pb(aa[i]);
}
dfs(1);
setHintLen(20);
for(int i=1;i<=n;i++){
//cout<<par[i]<<":"<<st[i]<<endl;
for(int k=0;k<10;k++){
if((1<<k)&par[i]){
setHint(i,k+1,1);
}
else{
setHint(i,k+1,0);
}
}
for(int k=0;k<10;k++){
if(i==n){
continue;
}
if((1<<k)&ind[st[i]+1]){
setHint(i,k+11,1);
}
else{
setHint(i,k+11,0);
}
}
}
}
void speedrun(int subtask, int n, int start) { /* your solution here */
int cur=start;
while(cur!=1){
int cur2=0;
for(int j=1;j<=10;j++){
int x=getHint(j);
if(x==1){
cur2+=(1<<(j-1));
}
}
cur=cur2;
goTo(cur);
}
for(int i=0;i<n-1;i++){
int ne=0;
for(int j=11;j<=20;j++){
int x=getHint(j);
if(x==1){
ne+=(1<<(j-11));
}
}
while(goTo(ne)==false){
int cur2=0;
for(int j=1;j<=10;j++){
int x=getHint(j);
if(x==1){
cur2+=(1<<(j-1));
}
}
cur=cur2;
goTo(cur);
}
cur=ne;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
196 ms |
688 KB |
Invalid node index to goTo |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
173 ms |
660 KB |
Output is correct |
2 |
Correct |
192 ms |
808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
185 ms |
656 KB |
Invalid node index to goTo |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
208 ms |
660 KB |
Invalid node index to goTo |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
177 ms |
660 KB |
Invalid node index to goTo |
2 |
Halted |
0 ms |
0 KB |
- |