이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int A[5000];
void solve(int N)
{
vector mem(N, vector<int>(3, -1));
auto qry = [&](int k, int d)
{
if (mem[k][d] == -1)
mem[k][d] = query(k + 1, k + d + 1);
return mem[k][d];
};
vector<bool> dir(N - 1);
vector<int> diff(N - 1);
diff[0] = qry(0, 1);
for (int i = 0; i < N - 2; i++)
{
int
x = qry(i, 1),
y = qry(i + 1, 1),
z = qry(i, 2);
dir[i + 1] = dir[i] ^ (x + y != z);
diff[i + 1] = y;
}
vector<int> a(N);
for (int i = 0; i < N - 1; i++)
a[i + 1] = a[i] + (dir[i] ? diff[i] : -diff[i]);
if (max_element(a.begin(), a.end()) < min_element(a.begin(), a.end()))
{
for (int i = 0; i < N; i++)
a[i] = -a[i];
}
int sub = *min_element(a.begin(), a.end());
for (int i = 0; i < N; i++)
a[i] = a[i] - sub;
for (int i = 0; i < N; i++)
answer(i + 1, a[i] + 1);
}
컴파일 시 표준 에러 (stderr) 메시지
xylophone.cpp:7:12: warning: 'A' defined but not used [-Wunused-variable]
7 | static int A[5000];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |