이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int MAX = 5010;
int a[MAX], d[MAX], t[MAX], dir[MAX];
void solve(int n) {
for(int i = 1; i + 1 <= n; ++i) {
d[i] = query(i, i + 1);
}
for(int i = 1; i + 2 <= n; ++i) {
t[i] = query(i, i + 2);
}
d[0] = 1;
for(int i = 1; i <= n; ++i) {
if(d[i] + d[i + 1] == t[i]) {
dir[i + 1] = dir[i];
} else {
dir[i + 1] = dir[i] ^ 1;
}
a[i] = a[i - 1] + (dir[i] ? d[i - 1] : -d[i - 1]);
}
int mn = 1, mx = 1;
for(int i = 1; i <= n; ++i) {
if(a[i] < a[mn]) mn = i;
if(a[i] > a[mx]) mx = i;
}
int x = a[mn];
for(int i = 1; i <= n; ++i) {
a[i] = a[i] - x + 1;
}
if(mn > mx) {
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... |