# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421770 | Pyqe | Zagonetka (COI18_zagonetka) | C++14 | 98 ms | 328 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;
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 (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... |