이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
int read(int place) {
int ans = 0;
for(int i=0; i<10; i++) {
ans*=2;
ans += getHint(place*10+i+1);
}
return ans;
}
void write(int x, int place, int v) {
for(int i=0; i<10; i++) {
setHint(x, place*10+i+1, v&(1<<(9-i)));
}
}
vector<int> adj[1004];
deque<int> unreached;
void dfs(int x, int p) {
write(x, 0, p);
int counter = 0;
for(auto i : adj[x]) {
if(i==p) continue;
if(counter==0) write(x, 1, i);
else unreached.push_back(i);
counter++;
}
for(auto i : adj[x]) {
if(i==p) continue;
dfs(i, x);
}
if(adj[x].size()==1 && unreached.size()>0) {
write(x, 1, unreached.front());
unreached.pop_front();
}
}
void assignHints(int st, 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);
}
void speedrun(int st, int n, int start) {
int curr = start;
while(curr != 1) {
int par = read(0);
goTo(par);
curr = par;
}
vector<int> depth{1};
while(true) {
int child = read(1);
if(child == 0) break;
if(goTo(child)) {
depth.push_back(child);
}
else {
while(true){
depth.pop_back();
goTo(depth.back());
if(goTo(child)) {
depth.push_back(child);
break;
}
}
}
}
}
# | 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... |