QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#467474#7679. Master of Both IVroger_yrjWA 24ms9072kbC++141.1kb2024-07-08 16:22:322024-07-08 16:22:32

Judging History

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

  • [2024-07-08 16:22:32]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:9072kb
  • [2024-07-08 16:22:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10,mod=998244353;
int a[N],n,ans=1,b[30],vis[N],cnt[N];
vector<int>g[N];
int qpow(int x){
	int y=2,ret=1;
	while(x){
		if(x&1)ret=1ll*ret*y%mod;
		y=1ll*y*y%mod;
		x>>=1;
	}
	return ret;
}
void solve(){
	ans=1;
	cin>>n;
	memset(b,0,sizeof(b));
	for(int i=1;i<=n;i++)cnt[i]=0,g[i].clear();
	for(int i=1;i<=n;i++){
		cin>>a[i];cnt[a[i]]++;
		int x=a[i];
		for(int j=20;j>=0;j--){
			if(x&(1<<j)){
				if(b[j])x^=b[j];
				else{
					b[j]=x;
					break;
				}
			}
		}
		if(!x)ans=1ll*ans*2%mod;
	}ans--;
	for(int i=1;i<=n;i++)
		if(cnt[i])
			for(int j=a[i];j<=n;j+=a[i])
				if(cnt[j])g[j].push_back(a[i]);
	for(int i=1;i<=n;i++){
		if(cnt[i]){
			int Cnt=0;
			memset(b,0,sizeof(b));
			for(int j:g[i]){
				Cnt+=cnt[j];
					for(int k=20;k>=0;k--){
						if(j&(1<<k)){
						if(b[k])j^=b[k];
						else{
							b[k]=j;
							break;
						}
					}
				}
				if(j)Cnt--;
			}
			ans=(1ll*ans+qpow(Cnt))%mod;
		}
	}
	cout<<ans<<"\n";
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T;cin>>T;
	while(T--)solve(); 
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 8860kb

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: 24ms
memory: 9072kb

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:

37
16
37
9
8
8
9
8
8
15
13
14
14
8
14
20
12
21
35
99
14
14
40
265
8
35
14
8
8
13
15
21
21
8
8
8
35
9
35
13
15
261
17
9
8
8
14
13
23
14
37
11
14
13
35
15
9
14
15
8
14
99
35
14
17
9
39
14
8
8
12
21
9
27
14
43
21
8
99
14
8
37
14
8
8
15
14
11
13
8
9
35
8
19
35
20
71
17
40
15
14
14
13
21
8
9
40
15
17
261...

result:

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