#include <bits/stdc++.h>
using namespace std;
long long n,a[169],pst[169],ca[169],sq[2][169];
bitset<169> spc,am[169];
int main()
{
long long i,j,r,ii,k,p,mn,mx;
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
scanf("%lld",a+i);
pst[a[i]]=i;
}
for(i=n;i;i--)
{
spc.reset();
spc[i]=1;
for(j=i+1;j<=n;j++)
{
if(spc[j])
{
continue;
}
p=0;
for(r=1;r<=j;r++)
{
if(!spc[r])
{
p++;
ca[pst[r]]=p;
}
}
for(r=i;r<=n;r++)
{
if(spc[r]||r>j)
{
p++;
ca[pst[r]]=p;
}
}
printf("query");
for(r=1;r<=n;r++)
{
printf(" %lld",ca[r]);
}
printf("\n");
fflush(stdout);
scanf("%lld",&k);
if(!k)
{
for(r=1;r<=n;r++)
{
if(r==j||am[j][r])
{
spc[r]=1;
am[i][r]=1;
}
}
}
}
}
for(i=1;i<=n;i++)
{
mn=i;
mx=n+1-i;
for(j=1;j<=n;j++)
{
if(am[a[i]][j]&&pst[j]<i)
{
mn=min(mn,sq[0][pst[j]]);
}
if(am[j][a[i]]&&pst[j]<i)
{
mx=max(mx,sq[1][pst[j]]);
}
}
sq[0][i]=mn;
sq[1][i]=mx;
for(j=1;j<i;j++)
{
sq[0][j]+=sq[0][j]>=mn;
sq[1][j]-=sq[1][j]<=mx;
}
}
printf("end\n");
for(ii=0;ii<2;ii++)
{
for(i=1;i<=n;i++)
{
printf("%lld%c",sq[ii][i]," \n"[i==n]);
}
}
fflush(stdout);
}
Compilation message
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
zagonetka.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%lld",a+i);
| ~~~~~^~~~~~~~~~~~
zagonetka.cpp:52:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%lld",&k);
| ~~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
200 KB |
Output is correct |
2 |
Correct |
24 ms |
200 KB |
Output is correct |
3 |
Correct |
39 ms |
200 KB |
Output is correct |
4 |
Correct |
47 ms |
200 KB |
Output is correct |
5 |
Correct |
11 ms |
200 KB |
Output is correct |
6 |
Correct |
42 ms |
200 KB |
Output is correct |
7 |
Correct |
6 ms |
200 KB |
Output is correct |
8 |
Correct |
8 ms |
200 KB |
Output is correct |
9 |
Correct |
37 ms |
200 KB |
Output is correct |
10 |
Correct |
17 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
7 ms |
200 KB |
Output is correct |
4 |
Correct |
6 ms |
200 KB |
Output is correct |
5 |
Correct |
3 ms |
200 KB |
Output is correct |
6 |
Correct |
4 ms |
200 KB |
Output is correct |
7 |
Correct |
5 ms |
200 KB |
Output is correct |
8 |
Correct |
7 ms |
200 KB |
Output is correct |
9 |
Correct |
5 ms |
200 KB |
Output is correct |
10 |
Correct |
3 ms |
200 KB |
Output is correct |
11 |
Correct |
7 ms |
200 KB |
Output is correct |
12 |
Correct |
6 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
200 KB |
Output is correct |
2 |
Correct |
94 ms |
200 KB |
Output is correct |
3 |
Correct |
81 ms |
200 KB |
Output is correct |
4 |
Correct |
2 ms |
200 KB |
Output is correct |
5 |
Correct |
3 ms |
200 KB |
Output is correct |
6 |
Correct |
3 ms |
200 KB |
Output is correct |
7 |
Correct |
20 ms |
200 KB |
Output is correct |
8 |
Correct |
33 ms |
200 KB |
Output is correct |
9 |
Correct |
25 ms |
200 KB |
Output is correct |
10 |
Correct |
85 ms |
200 KB |
Output is correct |
11 |
Correct |
76 ms |
200 KB |
Output is correct |
12 |
Correct |
74 ms |
200 KB |
Output is correct |
13 |
Correct |
98 ms |
200 KB |
Output is correct |
14 |
Correct |
85 ms |
200 KB |
Output is correct |
15 |
Correct |
63 ms |
200 KB |
Output is correct |
16 |
Correct |
78 ms |
200 KB |
Output is correct |