#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define pii pair<int, int>
int d[5005];
int a[5005];
void solve(int n) {
int id = 1;
int mx = 0;
for (int i = 2; i <= n; i++) {
int t = query(1, i);
if (t > mx) {
mx = t;
id = i;
}
}
int id2 = 0;
for (int i = 1; i <= n; i++) {
if (i == id) continue;
int t = query(min(id, i), max(id, i));
d[i] = t;
if (t == n - 1) {
id2 = i;
}
}
if (id > id2) {
a[id] = n;
for (int i = 1; i <= n; i++) {
if (id != i) {
a[i] = n - d[i];
}
}
}
else {
a[id] = 1;
for (int i = 1; i <= n; i++) {
if (id != i) {
a[i] = 1 + d[i];
}
}
}
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... |