이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
vector <int> conv (int x) {
vector <int> dd;
for (int i = 9; i >= 0; i--) {
dd.push_back((x >> i) & 1);
}
return dd;
}
void assignHints (int subtask, int n, int a[], int b[]) {
vector <int> adj[n + 1];
for (int i = 1; i < n; i++) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
setHintLen(20);
for (int i = 1; i <= n; i++) {
auto d = conv(adj[i][0]);
for (int l = 1; l <= 10; l++) {
setHint(i, l, d[l - 1]);
}
if (adj[i].size() == 1) continue;
d = conv(adj[i][1]);
for (int l = 1; l <= 10; l++) {
setHint(i, l + 10, d[l - 1]);
}
}
}
int n;
void dfs (int pos, int par) {
if (pos == 6) exit(0);
int x = 0;
for (int i = 1; i <= 10; i++) {
x *= 2; x += getHint(i);
}
if (x != 0 && x != par) {
goTo(x); dfs(x, pos); goTo(pos);
}
x = 0;
for (int i = 11; i <= 20; i++) {
x *= 2; x += getHint(i);
}
if (x != 0 && x != par) {
goTo(x); dfs(x, pos); goTo(pos);
}
}
void speedrun (int subtask, int N, int start) {
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... |