UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212298#3812. T2drdilyor501327ms52732kbC++111.6kb2024-10-13 18:19:492024-10-13 19:39:41

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
const int mod=998244353;
int n;
int a[100005];
int dp[100005][2];
int solve(vector<int> p,int x){
	int b=0;
	sort(p.begin(),p.end());
	while((1<<b)*2<=p.back())b++;
	if(x>=(1<<(b+1)))return 0;
	for(int i=0;i<=n;i++)dp[i][0]=dp[i][1]=0;
	dp[0][0]=1;
	for(int i=0;i<n-1;i++){
		if(p[i]>=(1<<b)){
			int l=p[i]+1-(1<<b);
			dp[i+1][0]=dp[i][1]*l%mod+dp[i][0]*(1<<b)%mod;
			dp[i+1][1]=dp[i][0]*l%mod+dp[i][1]*(1<<b)%mod;
			dp[i+1][0]%=mod,dp[i+1][1]%=mod;
		}
		else{
			dp[i+1][0]=dp[i][0]*(p[i]+1)%mod;
			dp[i+1][1]=dp[i][1]*(p[i]+1)%mod;
		}
	}
	int res=dp[n-1][x>=(1<<b)];
	if(p.back()>=(1<<b)){
		p.back()-=(1<<b);
		res+=solve(p,x^(1<<b));res%=mod;
	}
	return res;
}
int rdp[100005][65];
signed main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	if(n<=2000){
		vector<int> p;for(int i=1;i<=n;i++)p.push_back(a[i]);
		cout<<solve(p,0)<<"\n";
	}
	if(a[n]<=50){
		rdp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<64;j++){
				if(!rdp[i-1][j])continue;
				for(int k=0;k<=a[i];k++){
					rdp[i][(j^k)]+=rdp[i-1][j];
					rdp[i][(j^k)]%=mod;
				}
			}
		}
		cout<<rdp[n][0]<<"\n";
		return 0;
	}
	vector<int> p;for(int i=1;i<=n;i++)p.push_back(a[i]);
	cout<<solve(p,0)<<"\n";
	return 0;
}
//look at my code
//my code is amazing

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

10
3 5 0 1 0 3 5 4 2 5

output:

13248
13248

result:

wrong answer Output contains longer sequence [length = 2], but answer contains 1 elements

Subtask #2:

score: 10
Accepted

Test #2:

score: 10
Accepted
time: 407ms
memory: 52732kb

input:

100000
25 0 7 1 42 27 29 17 26 23 11 4 24 40 31 10 6 16 26 26 46 27 7 32 9 33 17 15 4 44 36 29 19 17...

output:

460821675

result:

ok 1 number(s): "460821675"

Subtask #3:

score: 10
Accepted

Test #3:

score: 10
Accepted
time: 300ms
memory: 52728kb

input:

100000
14 25 9 27 9 33 48 28 10 29 28 39 50 33 8 18 38 0 34 25 13 7 30 48 13 39 14 11 40 8 32 3 7 16...

output:

885189946

result:

ok 1 number(s): "885189946"

Subtask #4:

score: 10
Accepted

Test #4:

score: 10
Accepted
time: 17ms
memory: 5744kb

input:

100000
999998102 402961903 309346107 445160702 274308544 145846539 341002420 77841978 313436667 3206...

output:

714756233

result:

ok 1 number(s): "714756233"

Subtask #5:

score: 10
Accepted

Test #5:

score: 10
Accepted
time: 18ms
memory: 5748kb

input:

100000
999998479 400795186 127605328 439009686 279338791 222344190 32214702 347490239 390113609 1737...

output:

885251777

result:

ok 1 number(s): "885251777"

Subtask #6:

score: 10
Accepted

Test #6:

score: 10
Accepted
time: 14ms
memory: 5748kb

input:

100000
999980995 341927799 474797020 355936070 215296904 77682610 413850993 194378088 233473841 3566...

output:

99729538

result:

ok 1 number(s): "99729538"

Subtask #7:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 393ms
memory: 29080kb

input:

2000
540706819 309629779 17707890 194083691 334726587 456162964 498417390 246765617 957682339 604730...

output:

800177499
800177499

result:

wrong answer Output contains longer sequence [length = 2], but answer contains 1 elements

Subtask #8:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 178ms
memory: 14460kb

input:

2000
101722906 988313572 550840902 777765553 778991206 95817204 989809443 357040014 425595004 794587...

output:

443206431
443206431

result:

wrong answer Output contains longer sequence [length = 2], but answer contains 1 elements

Subtask #9:

score: 0
Time Limit Exceeded

Test #9:

score: 0
Time Limit Exceeded

input:

100000
327468559 836395032 98737045 14714567 147268924 355455125 829199457 117664948 79547712 117935...

output:


result:


Subtask #10:

score: 0
Time Limit Exceeded

Test #10:

score: 0
Time Limit Exceeded

input:

100000
334373908 573410989 584461609 757523993 595819683 93095595 866600961 552146722 657326632 1804...

output:


result: