QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290890#4900. 数列重排zyz0720 34ms5812kbC++171.1kb2023-12-25 19:36:522023-12-25 19:36:53

Judging History

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

  • [2023-12-25 19:36:53]
  • 评测
  • 测评结果:20
  • 用时:34ms
  • 内存:5812kb
  • [2023-12-25 19:36:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define For(Ti,Ta,Tb) for(auto Ti=(Ta);Ti<=(Tb);++Ti)
#define Dec(Ti,Ta,Tb) for(auto Ti=(Ta);Ti>=(Tb);--Ti)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define range(Tx) begin(Tx),end(Tx)
using ll=long long;
using i128=__int128;
const int M=1e7+5,Mod=998244353;
const ll Inv2=(Mod+1)/2;
int m,l,r,cnt;
char s[M];
ll sum(ll l,ll r){
	if(l>r) return 0;
	return ((l+r)%Mod)*((r-l+1)%Mod)%Mod*Inv2%Mod;
}
int main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	cin>>m>>l>>r>>cnt>>s;
	ll cur=cnt+s[0]-'0',n=1LL*m*cnt+count(s,s+m,'1'),pw=1,Ans=0;
	For(i,1,l){
		(pw*=233)%=Mod;
	}
	if(!l){
		Ans=sum(1,n);
		(pw*=233)%=Mod;
	}
	For(k,max(1,l),r){
		ll c=cur/k+1;
		i128 ans=sum(cur-2*(k-1),n-1-2*(k-1))+sum(1,cur-k+1);
		if(n-cur<=2*(k-1)){
			ll x1=(n-cur)/2,x2=(n-cur+1)/2;
			ans+=i128(k-1)*(n-cur)-sum(0,x1-1)-sum(0,x2-1);
		}else{
			ll left=n-cur-2*(k-1);
			ans+=sum(1,k-1)*2;
			ans-=i128(sum(1,left/c-1))*(c-left%c)+i128(sum(1,left/c))*(left%c);
		}
		ans=(ans%Mod+Mod)%Mod;
		Ans^=pw*ans%Mod;
		cur+=cnt+s[k]-'0';
		(pw*=233)%=Mod;
	}
	cout<<Ans<<'\n';
	return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 3480kb

input:

2 0 2 2
01

output:

541257

result:

ok 1 number(s): "541257"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

4 1 4 2
00001

output:

525797597

result:

ok 1 number(s): "525797597"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3428kb

input:

9 0 9 1
000000000

output:

711136343

result:

ok 1 number(s): "711136343"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

1 0 1 9
0

output:

10456

result:

ok 1 number(s): "10456"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3436kb

input:

2 1 2 3
11


output:

1518844

result:

ok 1 number(s): "1518844"

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #6:

score: 15
Accepted
time: 0ms
memory: 3476kb

input:

21 0 21 9
111010011100100100000

output:

171658329

result:

ok 1 number(s): "171658329"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

200 0 200 1
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

output:

287932632

result:

ok 1 number(s): "287932632"

Test #8:

score: -15
Wrong Answer
time: 1ms
memory: 3496kb

input:

120 3 119 1
101000110101001100011100001011101110101010000011101110010101101000111100111100001001010010110001110011001010110001101111

output:

998992496

result:

wrong answer 1st numbers differ - expected: '856785458', found: '998992496'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 5
Accepted

Test #14:

score: 5
Accepted
time: 1ms
memory: 3428kb

input:

2 0 1 114514
10

output:

934764137

result:

ok 1 number(s): "934764137"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

2 0 1 1919810
01

output:

685371514

result:

ok 1 number(s): "685371514"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3436kb

input:

2 0 1 500000000
00

output:

318651831

result:

ok 1 number(s): "318651831"

Subtask #5:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 4ms
memory: 4464kb

input:

1000000 1000000 1000000 928
01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...

output:

697615572

result:

wrong answer 1st numbers differ - expected: '437299311', found: '697615572'

Subtask #6:

score: 10
Accepted

Test #19:

score: 10
Accepted
time: 33ms
memory: 4412kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

852768823

result:

ok 1 number(s): "852768823"

Test #20:

score: 0
Accepted
time: 34ms
memory: 5812kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

852768823

result:

ok 1 number(s): "852768823"

Subtask #7:

score: 0
Wrong Answer

Test #21:

score: 15
Accepted
time: 3ms
memory: 4416kb

input:

1000000 0 9823 627
01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...

output:

383638431

result:

ok 1 number(s): "383638431"

Test #22:

score: -15
Wrong Answer
time: 0ms
memory: 5568kb

input:

1000000 456755 465755 982
0100111111100111100010100011110111111101011111101110010011101011110011111010110000110001101001011101000110111100110100101111101011111010101011101000011101100000000111000010101011011000111010101101111011100101010010000110101011110010101011111101110101100010000100001110000100...

output:

464331884

result:

wrong answer 1st numbers differ - expected: '982882798', found: '464331884'

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%