이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"xylophone.h"
#include<bits/stdc++.h>
using namespace std;
void solve(int n)
{
if (n == 2)
{
answer(1, 1), answer(2, 2);
return;
}
int d[5001], e[5001];
for (int i = 1; i <= n - 1; i++)
d[i] = query(i, i + 1);
for (int i = 1; i <= n - 2; i++)
e[i] = query(i, i + 2);
bool pp;
int ans[5001];
ans[1] = 1, ans[2] = ans[1] + d[1];
if (d[1] + d[2] == e[1])
ans[3] = ans[2] + d[2], pp = true;
else
ans[3] = ans[2] - d[2], pp = false;
for (int i = 4; i <= n; i++)
if (d[i - 2] + d[i - 1] == e[i - 2])
if (pp)
ans[i] = ans[i - 1] + d[i - 1];
else
ans[i] = ans[i - 1] - d[i - 1];
else
if (pp)
ans[i] = ans[i - 1] - d[i - 1], pp = false;
else
ans[i] = ans[i - 1] + d[i - 1], pp = true;
int mn = 1e9;
for (int i = 1; i <= n; i++)
mn = min(mn, ans[i]);
for (int i = 1; i <= n; i++)
ans[i] += -mn + 1;
bool ok;
for (int i = 1; i <= n; i++)
if (ans[i] == 1)
{
ok = true;
break;
}
else if (ans[i] == n)
{
ok = false;
break;
}
else;
if (!ok)
for (int i = 1; i <= n; i++)
ans[i] = n - ans[i] + 1;
for (int i = 1; i <= n; i++)
answer(i, ans[i]);
}
컴파일 시 표준 에러 (stderr) 메시지
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:59:5: warning: 'ok' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (!ok)
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |