This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
#define sz(x) (int)x.size()
#define fi first
#define se second
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 5005;
int n;
int a[maxn];
void solve(int N)
{
n = N;
int r = n - 1;
while(query(1, r) == n - 1)
--r;
++r; a[r] = n;
int l = 2;
while(query(2, l) == n - 1)
++l;
--l; a[l] = 1;
for(int i = 1; i < l; ++i)
a[i] = query(i, l) + 1;
for(int i = l + 1; i < r; ++i)
a[i] = n - query(i, r);
for(int i = r + 1; i <= n; ++i)
a[i] = n - query(r, 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... |