Submission #421770

#TimeUsernameProblemLanguageResultExecution timeMemory
421770PyqeZagonetka (COI18_zagonetka)C++14
100 / 100
98 ms328 KiB
#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)

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);
      |    ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...