QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#360736#5120. Power of TwoBaiyu0123WA 0ms3904kbC++143.3kb2024-03-22 02:59:582024-03-22 02:59:59

Judging History

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

  • [2024-03-22 02:59:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3904kb
  • [2024-03-22 02:59:58]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define mkp make_pair
#define pii pair<int,int>
#define ll long long
using namespace std;
const int maxk=17,maxn=1e5+100;
vector<int> ax,ay,az;
int c[maxn],ans[maxn],n;
void calc0(int y,int z) {
	for (int i=n-1;y&&i>=0;i--) {
		if (c[i]==0) continue;
		if (c[i]%2==1) {
			ans[i]=1;
			while (c[i]&&y) {
				ay.push_back(i);
				c[i]--;y--;
			}
		} else {
			if (z) {
				ans[i]=1;
				az.push_back(i);
				c[i]--;z--;
			}
			while (c[i]&&y) {
				ay.push_back(i);
				c[i]--;y--;
			}
		}
	}
	for (int i=n-1;i>=0;i--) {
		if (c[i]) {
			ans[i]=1;
			while (c[i]) {
				az.push_back(i);
				c[i]--;z--;
			}
			assert(z>=0);
		}
	}
	assert(z==0&&y==0);
}
void outputxyz() {
	for (int i:ax) printf("%d ",i);
	for (int i:ay) printf("%d ",i);
	for (int i:az) printf("%d ",i);
	printf("\n");
	ax.clear();ay.clear();az.clear();
}
void outputans() {
	for (int i=n-1;i>=0;i--) putchar('1'-ans[i]),ans[i]=0;
	putchar('\n');
}
void output(int cnt,int x,int y,int z) {
	while (cnt) cnt--,putchar('^');
	while (x) x--,putchar('&');
	while (y) y--,putchar('^');
	while (z) z--,putchar('|');
	putchar('\n');
}
int main() {
	int T;scanf("%d",&T);
	while (T--) {
		int x,y,z;
		scanf("%d",&n);scanf("%d",&x);scanf("%d",&z);scanf("%d",&y);
		int X=x,Y=y,Z=z;
		for (int i=1;i<=n;i++) {
			int wy;scanf("%d",&wy);
			c[wy]++;
		}
		if (x==0) {
			calc0(y,z);
			outputans();
			output(0,X,Y,Z);
			outputxyz();
			continue;
		}
		int a=0,G=0;
		for (int i=0;i<n;i++) {
			if (c[i]&&c[i]%2==0) a++;
			if (c[i]>1) G++;
		}
		if (a<=x) {
			for (int i=n-1;a&&i>=0;i--) {
				if (c[i]&&c[i]%2==0) {
					a--;x--;ax.push_back(i);c[i]--;
				}
			}
			for (int i=n-1;x>1&&i>=0;i--) {
				while (x>1&&c[i]>1) {
					x-=2;ax.push_back(i);ax.push_back(i);c[i]-=2;
				}
			}
			if (x==1) {
				if (z!=0) {
					for (int i=n-1;i>=0;i--) {
						if (c[i]>1) {
							x--;c[i]--;ax.push_back(i);
							break;
						}
					}
					if (x==0) {
						calc0(y,z);
						outputans();
						output(0,X,Y,Z);
						outputxyz();
						continue;
					}
				} else if (X==1||G==1) {
					for (int i=0;i<n;i++) {
						if (c[i]) {
							x--;c[i]--;ax.push_back(i);
							break;
						}
					}
					calc0(y,z);
					outputans();
					output(0,X,Y,Z);
					outputxyz();
					continue;
				} else {
					for (int i=0;i<n;i++) {
						if (c[i]>1) {
							x--;c[i]--;ax.push_back(i);
							vector<int> wy;wy.clear();
							y--;c[i]--;wy.push_back(i);
							swap(ax,wy);
							for (int j:wy) ax.push_back(j);
							wy.clear();
							break;
						}
					}
					if (x==0) {
						calc0(y,z);
						outputans();
						output(1,X,Y-1,Z);
						outputxyz();
						continue;
					}
				}
			}
			for (int i=0;x&&i<n;i++) {
				if (c[i]) {
					x--;c[i]--;ax.push_back(i);
				}
			}
			calc0(y,z);
			outputans();
			output(0,X,Y,Z);
			outputxyz();
			continue;
		}
		for (int i=n-1;x&&i>=0;i--) {
			if (c[i]&&c[i]%2==0) {
				x--;c[i]--;ax.push_back(i);
			}
		}
		int cnt=0;
		for (int i=n-1;y&&i>=0;i--) {
			if (c[i]&&c[i]%2==0) {
				cnt++;y--;c[i]--;ax.push_back(i);
			}
		}
		calc0(y,z);
		outputans();
		output(cnt,X,Y-cnt,Z);
		outputxyz();
		continue;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

4
4 3 0 1
1 0 1 0
4 1 0 3
1 0 1 0
8 0 2 6
1 5 5 7 1 5 5 7
8 0 0 8
1 5 5 7 1 5 5 7

output:

1101
&&&^
1 0 0 1 
1100
^&^^
1 0 1 0 
01011111
^^^^^^||
7 5 5 5 1 1 7 5 
11111111
^^^^^^^^
7 7 5 5 5 5 1 1 

result:

wrong answer wrong construction (test case 1)