이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int MAXN = 5000;
int m;
int a[MAXN+1];
int d[MAXN+1];
bool p[MAXN+1];
void solve(int n) {
for (int i = 2; i <= n; i++)
d[i] = query(i-1, i);
for (int i = 3; i <= n; i++) {
if (d[i-1] + d[i] == query(i-2, i)) {
p[i] = p[i-1];
} else p[i] = !p[i-1];
}
for (int i = 2; i <= n; i++) {
if (p[i]) a[i] = a[i-1] + d[i];
else a[i] = a[i-1] - d[i];
m = min(m, a[i]);
}
for (int i = 1; i <= n; i++)
a[i] = a[i] - m + 1;
bool tf = 0, t = 0;
for (int i = 1; i <= n; i++) {
if (a[i] == 1) t = 1;
if (a[i] == n && !t) tf = 1;
}
if (tf)
for (int i = 1; i <= n; i++)
a[i] = n - a[i] + 1;
for (int i = 1; i <= n; i++)
answer(i, a[i]);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |