이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
const int maxn = 1e3 + 2;
// bool ad [maxn][maxn];
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
vector <int> ad [maxn];
setHintLen(20);
for (int i = 1; i < N; i++){
ad[A[i]].push_back(B[i]);
ad[B[i]].push_back(A[i]);
}
vector <int> euler;
int l[maxn] = {}, r [maxn] = {}, pr[maxn] = {};
auto dfs = [&] (int i, int p, auto&& dfs) -> void {
// cerr << i << " ";
euler.push_back(i);
pr[i] = p;
for (int j: ad[i]) {
if (j == p) continue;
dfs(j, i, dfs);
}
};
dfs(1, -1, dfs);
for (int i = 0; i < N; i++){
r[euler[i]] = euler[(i + 1) % N];
}
for (int i = 1; i <= N; i++){
for (int b = 0; b <= 9; b++){
setHint(i, b + 1, (pr[i] & (1 << b)));
setHint(i, b + 11, (r[i] & (1 << b)));
}
// cout << i << " " << l[i] << " " << r[i] << " " << pr[i] << "\n";
// if (l[i]) cout << i << " " << l[i] << "\n";
// if (r[i]) cout << i << " " << r[i] << "\n";
}
}
void speedrun(int subtask, int N, int s) { /* your solution here */
int vis [maxn] = {};
while (!vis[s]) {
vis[s] = 1;
int l = 0, r = 0;
for (int i = 0; i <= 9; i++){
l+=((1 << i) * getHint(i + 1));
r+=((1 << i) * getHint(i + 11));
}
// cout << s << " " << l << " " << r << "\n";
while (!goTo(r)) {
goTo(l);
s = l;
l = 0;
for (int i = 0; i <= 9; i++){
l+=((1 << i) * getHint(i + 1));
}
}
s = r;
}
}
컴파일 시 표준 에러 (stderr) 메시지
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:15:9: warning: unused variable 'l' [-Wunused-variable]
15 | int l[maxn] = {}, r [maxn] = {}, pr[maxn] = {};
| ^
# | 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... |