QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120710#4327. Šeširiyoungsystem#Compile Error//C++202.3kb2023-07-07 10:17:102024-05-26 01:47:59

Judging History

你现在查看的是最新测评结果

  • [2024-05-26 01:47:59]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-07 10:17:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
vector<int>v[1000005];
int bu[10000005],bv[10000005],fx[10000005],vis[10000005],cnt;
bool visd[2000005];
int now[1000005];
void dfs(int x)
{
	visd[x]=true;
	for(int i=now[x];i<v[x].size();i=now[x])
	{
		if(vis[v[x][i]])
		{
			now[x]=i+1;
			continue;
		}
		vis[v[x][i]]=true;
		now[x]=i+1;
		if(x==bu[v[x][i]])fx[v[x][i]]=0;
		else fx[v[x][i]]=1;
		int sth=bu[v[x][i]]+bv[v[x][i]]-x;
		dfs(sth);
	}
	sta[++ttop]=x;
}
int qans[20][500005];
int main()
{
	int n;
	n=read();
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i&(1<<(j-1)))continue;
			cnt++;
			bu[cnt]=2*i;
			bv[cnt]=2*(i^(1<<(j-1)))+1;
			v[bu[cnt]].push_back(cnt);
			v[bv[cnt]].push_back(cnt);
		}
	}
	for(int i=0;i<2*(1<<n);i++)
	{
		int sth=(int)v[i].size();
		if(sth%2==1)
		{
			cnt++;
			bu[cnt]=i;
			bv[cnt]=2*(1<<n);
			v[bu[cnt]].push_back(cnt);
			v[bv[cnt]].push_back(cnt);
		}
	}
	for(int i=0;i<=2*(1<<n);i++)
	{
		if(!visd[i])dfs(i);
	}
	for(int i=1;i<=cnt;i++)
	{
		if(bv[i]==2*(1<<n))continue;
		int bh=-1;
		for(int j=1;j<=n;j++)
		{
			if((bu[i]^bv[i])&(1<<j))
			{
				bh=j;
				break;
			}
		}
		int sy=0;
		for(int j=1;j<=n;j++)
		{
			if(j==bh)continue;
			int now=0;
			if((bu[i])&(1<<j))now=1;
			sy=sy*2+now;
		}
		if(fx[i]==0)qans[bh][sy]=0;
		else qans[bh][sy]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<(1<<(n-1));j++)
		{
			if(qans[i][j])printf("C");
			else printf("B");
		}
		printf("\n");
	}
	return 0;
	for(int i=0;i<(1<<n);i++)
	{
		int z0=0,z1=0;
		for(int j=1;j<=n;j++)
		{
			if(i&(1<<(j-1)))z1++;
			else z0++;
		}
		int d0=0,d1=0;
		for(int j=1;j<=n;j++)
		{
			int sth=0;
			for(int k=1;k<=n;k++)
			{
				if(k==j)continue;
				if(i&(1<<(k-1)))sth=sth*2+1;
				else sth=sth*2;
			}
			int ans=0;
			if(i&(1<<(j-1)))ans=1;
			if(qans[j][sth]==0&&ans==0)d0++;
			if(qans[j][sth]==1&&ans==1)d1++;
		}
		if(d0<z0/2||d1<z1/2)
		{
			printf("wa %d %d %d %d %d\n",i,d0,z0,d1,z1);
			return 0;
		}
	}
	printf("ac\n");
	return 0;
}

Details

answer.code: In function ‘void dfs(int)’:
answer.code:39:9: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
   39 |         sta[++ttop]=x;
      |         ^~~
      |         std
answer.code:39:15: error: ‘ttop’ was not declared in this scope
   39 |         sta[++ttop]=x;
      |               ^~~~