QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#360734 | #5120. Power of Two | Baiyu0123 | WA | 96ms | 4532kb | C++14 | 3.3kb | 2024-03-22 02:54:14 | 2024-03-22 02:54:15 |
Judging History
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('0'+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;
}
}
详细
Test #1:
score: 100
Accepted
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:
0010 &&&^ 1 0 0 1 0011 ^&^^ 1 0 1 0 10100000 ^^^^^^|| 7 5 5 5 1 1 7 5 00000000 ^^^^^^^^ 7 7 5 5 5 5 1 1
result:
ok ok the answer is correct (4 test cases)
Test #2:
score: 0
Accepted
time: 96ms
memory: 4532kb
input:
16 65511 1 1 65509 42389 52308 9452 29149 28980 48173 38152 51625 29991 48293 12319 38611 47245 11954 45410 33185 30976 56806 18986 35564 25430 48493 26311 19090 42172 33403 62406 15847 51266 33712 53139 15610 50006 62298 28716 19191 3057 35733 12331 14483 9604 16610 18534 32110 35673 5239 31310 279...
output:
011100011111111101111001001110101111111101101101011111011100100111011110101110111110111001110100111101110110111100111101101101111110110101011011111111011111110111000110010000010111011100111101111101111111010001010110100100000110101000001011101011001111110011101111010011101101111010101110011101111110...
result:
ok ok the answer is correct (16 test cases)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
3 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0
output:
1 ^ 0 1 | 0 0 & 0
result:
ok ok the answer is correct (3 test cases)
Test #4:
score: 0
Accepted
time: 0ms
memory: 4132kb
input:
12 2 0 0 2 0 0 2 0 1 1 0 0 2 0 2 0 0 0 2 1 0 1 0 0 2 1 1 0 0 0 2 2 0 0 0 0 2 0 0 2 0 1 2 0 1 1 0 1 2 0 2 0 0 1 2 1 0 1 0 1 2 1 1 0 0 1 2 2 0 0 0 1
output:
00 ^^ 0 0 01 ^| 0 0 01 || 0 0 01 &^ 0 0 01 &| 0 0 00 && 0 0 11 ^^ 1 0 11 ^| 1 0 11 || 1 0 10 &^ 0 1 10 &| 0 1 00 && 0 1
result:
ok ok the answer is correct (12 test cases)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
40 3 0 0 3 0 0 0 3 0 1 2 0 0 0 3 0 2 1 0 0 0 3 0 3 0 0 0 0 3 1 0 2 0 0 0 3 1 1 1 0 0 0 3 1 2 0 0 0 0 3 2 0 1 0 0 0 3 2 1 0 0 0 0 3 3 0 0 0 0 0 3 0 0 3 0 1 1 3 0 1 2 0 1 1 3 0 2 1 0 1 1 3 0 3 0 0 1 1 3 1 0 2 0 1 1 3 1 1 1 0 1 1 3 1 2 0 0 1 1 3 2 0 1 0 1 1 3 2 1 0 0 1 1 3 3 0 0 0 1 1 3 0 0 3 0 0 1 3 0...
output:
001 ^^^ 0 0 0 001 ^^| 0 0 0 001 ^|| 0 0 0 001 ||| 0 0 0 000 &^^ 0 0 0 001 &^| 0 0 0 001 &|| 0 0 0 001 &&^ 0 0 0 001 &&| 0 0 0 000 &&& 0 0 0 001 ^^^ 1 1 0 011 ^^| 1 0 1 011 ^|| 1 1 0 011 ||| 1 1 0 011 &^^ 1 1 0 011 &^| 1 1 0 011 &|| 1 1 0 010 &&^ 1 0 1 010 &&| 1 0 1 000 &&& 1 0 1 ...
result:
ok ok the answer is correct (40 test cases)
Test #6:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
120 4 0 0 4 0 0 0 0 4 0 1 3 0 0 0 0 4 0 2 2 0 0 0 0 4 0 3 1 0 0 0 0 4 0 4 0 0 0 0 0 4 1 0 3 0 0 0 0 4 1 1 2 0 0 0 0 4 1 2 1 0 0 0 0 4 1 3 0 0 0 0 0 4 2 0 2 0 0 0 0 4 2 1 1 0 0 0 0 4 2 2 0 0 0 0 0 4 3 0 1 0 0 0 0 4 3 1 0 0 0 0 0 4 4 0 0 0 0 0 0 4 0 0 4 1 1 0 1 4 0 1 3 1 1 0 1 4 0 2 2 1 1 0 1 4 0 3 1 ...
output:
0000 ^^^^ 0 0 0 0 0001 ^^^| 0 0 0 0 0001 ^^|| 0 0 0 0 0001 ^||| 0 0 0 0 0001 |||| 0 0 0 0 0001 &^^^ 0 0 0 0 0001 &^^| 0 0 0 0 0001 &^|| 0 0 0 0 0001 &||| 0 0 0 0 0000 &&^^ 0 0 0 0 0001 &&^| 0 0 0 0 0001 &&|| 0 0 0 0 0001 &&&^ 0 0 0 0 0001 &&&| 0 0 0 0 0000 &&&& 0 0 0 0 0011 ^^^^ 1 1 1...
result:
ok ok the answer is correct (120 test cases)
Test #7:
score: 0
Accepted
time: 1ms
memory: 3844kb
input:
336 5 0 0 5 0 0 0 0 0 5 0 1 4 0 0 0 0 0 5 0 2 3 0 0 0 0 0 5 0 3 2 0 0 0 0 0 5 0 4 1 0 0 0 0 0 5 0 5 0 0 0 0 0 0 5 1 0 4 0 0 0 0 0 5 1 1 3 0 0 0 0 0 5 1 2 2 0 0 0 0 0 5 1 3 1 0 0 0 0 0 5 1 4 0 0 0 0 0 0 5 2 0 3 0 0 0 0 0 5 2 1 2 0 0 0 0 0 5 2 2 1 0 0 0 0 0 5 2 3 0 0 0 0 0 0 5 3 0 2 0 0 0 0 0 5 3 1 1 ...
output:
00001 ^^^^^ 0 0 0 0 0 00001 ^^^^| 0 0 0 0 0 00001 ^^^|| 0 0 0 0 0 00001 ^^||| 0 0 0 0 0 00001 ^|||| 0 0 0 0 0 00001 ||||| 0 0 0 0 0 00000 &^^^^ 0 0 0 0 0 00001 &^^^| 0 0 0 0 0 00001 &^^|| 0 0 0 0 0 00001 &^||| 0 0 0 0 0 00001 &|||| 0 0 0 0 0 00001 &&^^^ 0 0 0 0 0 00001 &&^^| 0 0 0 0 0 0...
result:
ok ok the answer is correct (336 test cases)
Test #8:
score: 0
Accepted
time: 1ms
memory: 4136kb
input:
896 6 0 0 6 0 0 0 0 0 0 6 0 1 5 0 0 0 0 0 0 6 0 2 4 0 0 0 0 0 0 6 0 3 3 0 0 0 0 0 0 6 0 4 2 0 0 0 0 0 0 6 0 5 1 0 0 0 0 0 0 6 0 6 0 0 0 0 0 0 0 6 1 0 5 0 0 0 0 0 0 6 1 1 4 0 0 0 0 0 0 6 1 2 3 0 0 0 0 0 0 6 1 3 2 0 0 0 0 0 0 6 1 4 1 0 0 0 0 0 0 6 1 5 0 0 0 0 0 0 0 6 2 0 4 0 0 0 0 0 0 6 2 1 3 0 0 0 0 ...
output:
000000 ^^^^^^ 0 0 0 0 0 0 000001 ^^^^^| 0 0 0 0 0 0 000001 ^^^^|| 0 0 0 0 0 0 000001 ^^^||| 0 0 0 0 0 0 000001 ^^|||| 0 0 0 0 0 0 000001 ^||||| 0 0 0 0 0 0 000001 |||||| 0 0 0 0 0 0 000001 &^^^^^ 0 0 0 0 0 0 000001 &^^^^| 0 0 0 0 0 0 000001 &^^^|| 0 0 0 0 0 0 000001 &^^||| 0 0 0 0 0 0 000...
result:
ok ok the answer is correct (896 test cases)
Test #9:
score: -100
Wrong Answer
time: 3ms
memory: 3840kb
input:
2304 7 0 0 7 0 0 0 0 0 0 0 7 0 1 6 0 0 0 0 0 0 0 7 0 2 5 0 0 0 0 0 0 0 7 0 3 4 0 0 0 0 0 0 0 7 0 4 3 0 0 0 0 0 0 0 7 0 5 2 0 0 0 0 0 0 0 7 0 6 1 0 0 0 0 0 0 0 7 0 7 0 0 0 0 0 0 0 0 7 1 0 6 0 0 0 0 0 0 0 7 1 1 5 0 0 0 0 0 0 0 7 1 2 4 0 0 0 0 0 0 0 7 1 3 3 0 0 0 0 0 0 0 7 1 4 2 0 0 0 0 0 0 0 7 1 5 1 0...
output:
0000001 ^^^^^^^ 0 0 0 0 0 0 0 0000001 ^^^^^^| 0 0 0 0 0 0 0 0000001 ^^^^^|| 0 0 0 0 0 0 0 0000001 ^^^^||| 0 0 0 0 0 0 0 0000001 ^^^|||| 0 0 0 0 0 0 0 0000001 ^^||||| 0 0 0 0 0 0 0 0000001 ^|||||| 0 0 0 0 0 0 0 0000001 ||||||| 0 0 0 0 0 0 0 0000000 &^^^^^^ 0 0 0 0 0 0 0 0000001 &^^^^^| 0 0 0...
result:
wrong answer wrong construction (test case 304)