이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "speedrun.h"
#include <bits/stdc++.h>
#include <vector>
#include <stack>
using namespace std;
const int NMAX = 1001;
vector<int> adj[NMAX];
stack<int> ord;
void setPar (int nod , int par)
{
int bit = 1;
while (par)
{
setHint(nod , bit , par&1);
bit++;
par /= 2;
}
}
void setNext (int nod , int nxt)
{
int bit = 11;
while (nxt)
{
setHint(nod , bit , nxt&1);
bit++;
nxt /= 2;
}
}
void dfs (int nod = 1 , int par = 0)
{
ord.push(nod);
for (auto& to : adj[nod])
{
if (to == par) continue;
setPar(to , nod);
dfs(to , nod);
}
}
void assignHints(int subtask, 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();
int prev = 1;
while (ord.size())
{
setNext(ord.top() , prev);
prev = ord.top();
ord.pop();
}
}
int getPar (int nod)
{
int par = 0;
for (int bit = 1; bit <= 10; bit++)
{
par = par << 1 + getHint(bit);
}
return par;
}
int getNext (int nod)
{
int nxt = 0;
for (int bit = 11; bit <= 20; bit++)
{
nxt = nxt << 1 + getHint(bit);
}
return nxt;
}
void speedrun(int subtask, int N, int start)
{
vector<bool> viz(N+1, 0);
int visited = 0;
int crt = start;
while (visited < N)
{
int par = getPar(crt);
int nxt = getNext(crt);
if (goTo(nxt) == 0) goTo(par);
}
}
컴파일 시 표준 에러 (stderr) 메시지
speedrun.cpp: In function 'int getPar(int)':
speedrun.cpp:67:24: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
67 | par = par << 1 + getHint(bit);
| ~~^~~~~~~~~~~~~~
speedrun.cpp: In function 'int getNext(int)':
speedrun.cpp:77:24: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
77 | nxt = nxt << 1 + getHint(bit);
| ~~^~~~~~~~~~~~~~
# | 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... |