# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370637 | arnold518 | Zagonetka (COI18_zagonetka) | C++14 | 3 ms | 512 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;
int bef=1;
for(int i=1; i<=N; i++)
{
for(int j=1; j<=N; j++)
{
P[j]=A[j]+i;
if(P[j]>N) P[j]-=N;
}
int t=query();
if(bef!=t)
{
if(t==1)
{
a=1;
for(int i=1; i<=N; i++) if(P[a]>P[i]) a=i;
}
else
{
b=1;
for(int i=1; i<=N; i++) if(P[b]>P[i]) b=i;
}
}
bef=t;
}
if(a>b) swap(a, b);
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... |