이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << ": " << x << endl;
#define sep ' '
const ll MAXN = 5000 + 10;
int A[MAXN], n, B[MAXN], S[MAXN], P[MAXN];
bool C[MAXN];
bool final_ans() {
int mn = *min_element(S + 1, S + n + 1);
for (int i = 1; i <= n; i++) S[i] -= mn - 1, debug(S[i]);
if (!is_permutation(S + 1, S + n + 1, P + 1, P + n + 1) || min_element(S + 1, S + n + 1) - max_element(S + 1, S + n + 1) >= 0) return false;
for (int i = 1; i <= n; i++)
answer(i, S[i]);
return true;
}
void solve(int N) {
n = N;
for (int i = 1; i <= n; i++) P[i] = i;
for (int i = 1; i < n; i++)
B[i] = query(i, i + 1);
for (int i = 1; i < n - 1; i++) {
int x = query(i, i + 2);
C[i + 1] = (x != B[i] + B[i + 1]);
}
S[1] = 1;
bool b = true;
for (int i = 2; i <= n; i++) {
S[i] = S[i - 1] + (b ? 1 : -1) * B[i - 1];
b ^= C[i];
}
if (!final_ans()) {
bool b = false;
for (int i = 2; i <= n; i++) {
S[i] = S[i - 1] + (b ? 1 : -1) * B[i - 1];
b ^= C[i];
}
final_ans();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |