QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275829#7679. Master of Both IVship2077WA 7ms3796kbC++14978b2023-12-05 09:01:182023-12-05 09:01:19

Judging History

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

  • [2023-12-05 09:01:19]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3796kb
  • [2023-12-05 09:01:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=2e5+5,mod=998244353;
int n,m,ans,cnt,sum,p[20],pw[M],buc[M];
int read(){
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
	return x*f;
}
int reduce(int x){return x>=mod?x-mod:x;}
void insert(int x){
	for (int i=m;~i;i--)
		if (x>>i&1){
			if (!p[i]) {p[i]=x;cnt++;break;}
			x^=p[i];
		}
}
bool check(int x){
	for (int i=m;~i;i--)
		if (x>>i&1) x^=p[i];
	return !x;
}
void solve(){ n=read();m=__lg(n);
	for (int i=1;i<=n;i++) buc[read()]++;
	for (int i=pw[0]=1;i<=n;i++) pw[i]=reduce(pw[i-1]*2);
	for (int i=1;i<=n;i++){ cnt=sum=0;
		for (int j=0;j<=m;j++) p[j]=0;
		for (int j=i;j<=n;j++)
			if (buc[j]) sum+=buc[j],insert(j);
		if (check(i)) ans=reduce(ans+pw[sum-cnt]);
	}
	printf("%d\n",ans);
	for (int i=1;i<=n;i++) buc[i]=0;
}
int main(){int T=read();
	while (T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

2
3
1 2 3
5
3 3 5 1 1

output:

4
11

result:

ok 2 number(s): "4 11"

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3796kb

input:

40000
5
4 2 5 5 5
5
5 5 5 5 4
5
1 4 4 4 2
5
2 5 2 4 1
5
3 2 4 5 3
5
1 5 5 3 4
5
5 5 5 4 3
5
4 3 3 5 1
5
4 5 5 2 1
5
2 5 4 2 5
5
3 4 3 4 3
5
5 3 5 1 3
5
5 1 2 4 4
5
4 2 5 1 5
5
5 4 2 5 4
5
5 2 5 2 4
5
1 4 5 4 5
5
4 2 3 2 3
5
1 4 1 3 5
5
1 1 2 1 5
5
5 2 5 1 3
5
3 1 2 5 3
5
5 5 1 1 5
5
2 2 2 1 3
5
3 1 ...

output:

16
40
52
60
72
84
104
114
124
136
146
156
165
175
189
201
215
226
234
240
250
259
271
284
293
300
310
322
336
349
360
368
379
388
397
409
416
424
432
448
460
480
492
508
517
527
536
548
555
565
582
589
600
614
622
634
642
652
663
672
681
687
695
704
716
727
738
750
760
770
784
792
805
813
822
829
83...

result:

wrong answer 1st numbers differ - expected: '9', found: '16'