QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72867#5120. Power of TwozhouhuanyiCompile Error//C++113.4kb2023-01-19 18:47:222023-01-19 18:47:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-19 18:47:25]
  • 评测
  • [2023-01-19 18:47:22]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cassert>
#define N 65536
using namespace std;
int read()
{
    char c=0;
    int sum=0;
    while (c<'0'||c>'9') c=getchar();
    while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
    return sum;
}
int T,n,x,y,z,rcnt[N+1];
bool used[N+1],vis[N+1];
vector<int>p[N+1];
int main()
{
    vector<int>A;
    vector<int>B;
    vector<int>C;
    vector<int>D;
    int d,op;
    T=read();
    while (T--)
    {
	n=read(),x=read(),z=read(),y=read(),A.clear(),B.clear(),C.clear(),D.clear(),opt=0;
	for (int i=0;i<=n-1;++i) rcnt[i]=used[i]=vis[i]=0;
	for (int i=1;i<=n;++i) d=read(),rcnt[d]++;
	if (x)
	{
	    if (z)
	    {
		for (int i=n-1;i>=0;--i)
		    if (rcnt[i])
		    {
			if (rcnt[i]>=2&&z) z--,D.push_back(i),rcnt[i]--,used[i]=vis[i]=1;
			else if (y) y--,C.push_back(i),rcnt[i]--,used[i]=1;
			else if (z) z--,D.push_back(i),rcnt[i]--,used[i]=vis[i]=1;
			while (rcnt[i])
			{
			    if (x) x--,B.push_back(i),rcnt[i]--;
			    else if (y) y--,C.push_back(i),rcnt[i]--;
			    else z--,D.push_back(i),rcnt[i]--;
			}
		    }
		for (int i=0;i<=n-1;++i) rcnt[i]=0;
		for (int i=0;i<C.size();++i) rcnt[C[i]]++;
		for (int i=0;i<=n-1;++i)
		    if (rcnt[i]&&!(rcnt[i]&1)&&!vis[i])
			A.push_back(i),rcnt[i]--;
		C.clear();
		for (int i=0;i<=n-1;++i)
		    for (int j=1;j<=rcnt[i];++j)
			C.push_back(i);
	    }
	    else
	    {
		for (int i=n-1;i>=0;--i)
		    if (rcnt[i]&&y)
			y--,C.push_back(i),rcnt[i]--,used[i]=1;
		for (int i=0;i<=n-1;++i)
		    if (rcnt[i]&&x)
			x--,B.push_back(i),rcnt[i]--;
		for (int i=0;i<=n-1;++i)
		    while (rcnt[i])
		    {
			if (x) x--,B.push_back(i),rcnt[i]--;
			else y--,C.push_back(i),rcnt[i]--;
		    }
		op=1;
		for (int i=1;i<B.size();++i) op&=(B[0]==B[i]);
		for (int i=0;i<=n-1;++i) rcnt[i]=0;
		for (int i=0;i<C.size();++i) rcnt[C[i]]++;
		if (op&&(!(rcnt[B[0]]&1)))
		{
		    op=0;
		    for (int i=0;i<=n-1;++i)
			if (i!=B[0]&&rcnt[i]&&!(rcnt[i]&1))
			{
			    rcnt[i]--,rcnt[B[0]]++,B.pop_back(),B.push_back(i),op=1;
			    break;
			}
		    if (!op)
		    {
			for (int i=0;i<B[0];++i)
			    if (rcnt[i])
			    {
				rcnt[i]--,rcnt[B[0]]++,B.pop_back(),B.push_back(i),used[i]=0,op=1;
				break;
			    }
		    }
		    if (!op) used[B[0]]=0;
		}
		for (int i=0;i<=n-1;++i)
		    if (rcnt[i]&&!(rcnt[i]&1))
			A.push_back(i),rcnt[i]--;
		C.clear();
		for (int i=0;i<=n-1;++i)
		    for (int j=1;j<=rcnt[i];++j)
			C.push_back(i);
	    }
	}
	else
	{
	    for (int i=n-1;i>=0;--i)
		if (rcnt[i])
		{
		    used[i]=1;
		    if (!(rcnt[i]&1))
		    {
			if (z) D.push_back(i),rcnt[i]--,z--;
			else used[i]=0;
		    }
		}
	    for (int i=n-1;i>=0;--i)
		while (rcnt[i]&&z)
		    D.push_back(i),rcnt[i]--,z--;
	    for (int i=0;i<=n-1;++i)
		for (int j=1;j<=rcnt[i];++j)
		    C.push_back(i);
	}
	for (int i=n-1;i>=0;--i) printf("%d",used[i]);
	puts("");
	for (int i=0;i<A.size();++i) printf("^");
	for (int i=0;i<B.size();++i) printf("&");
	for (int i=0;i<C.size();++i) printf("^");
	for (int i=0;i<D.size();++i) printf("|");
	puts("");
	for (int i=0;i<A.size();++i) printf("%d ",A[i]);
	for (int i=0;i<B.size();++i) printf("%d ",B[i]);
	for (int i=0;i<C.size();++i) printf("%d ",C[i]);
	for (int i=0;i<D.size();++i) printf("%d ",D[i]);
	puts("");
    }
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:29:85: error: ‘opt’ was not declared in this scope; did you mean ‘op’?
   29 |         n=read(),x=read(),z=read(),y=read(),A.clear(),B.clear(),C.clear(),D.clear(),opt=0;
      |                                                                                     ^~~
      |                                                                                     op