# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370630 | arnold518 | Zagonetka (COI18_zagonetka) | C++14 | 2 ms | 364 KiB |
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>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 100;
int N, A[MAXN+10], P[MAXN+10];
int query()
{
printf("query ");
for(int i=1; i<=N; i++) printf("%d ", P[i]);
printf("\n");
fflush(stdout);
int t;
scanf("%d", &t);
return t;
}
int main()
{
scanf("%d", &N);
for(int i=1; i<=N; i++) scanf("%d", &A[i]);
int a=-1, b=-1;
for(int i=1; i<=N; i++)
{
for(int j=i+1; j<=N; j++)
{
for(int k=1; k<=N; k++) P[k]=A[k];
swap(P[i], P[j]);
if(!query())
{
a=i; b=j;
break;
}
if(a!=-1) break;
}
if(a!=-1) break;
}
printf("end\n"); fflush(stdout);
if(A[a]<A[b])
{
for(int i=1; i<=N; i++) printf("%d ", i);
printf("\n");
}
else
{
for(int i=1; i<=N; i++)
{
if(i<a || b<i) printf("%d ", i);
else if(i==a) printf("%d ", a+1);
else if(i==b) printf("%d ", a);
else printf("%d ", i+1);
}
printf("\n");
}
fflush(stdout);
if(A[a]>A[b])
{
for(int i=1; i<=N; i++) printf("%d ", N-i+1);
printf("\n");
}
else
{
for(int i=1; i<=N; i++)
{
if(i<a || b<i) printf("%d ", N-i+1);
else if(i==a) printf("%d ", N-a);
else if(i==b) printf("%d ", N-a+1);
else printf("%d ", N-i);
}
printf("\n");
}
fflush(stdout);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |