QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#91107#4900. 数列重排xyw10 24ms12464kbC++141.3kb2023-03-27 12:30:202023-03-27 12:30:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-27 12:30:21]
  • 评测
  • 测评结果:10
  • 用时:24ms
  • 内存:12464kb
  • [2023-03-27 12:30:20]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int _=1e7+7,mod=998244353;
int m,l,r,X,n,pw[_],ans[_],res,Sum[_];
char s[_];
ll calc(int i,int j,int s0,int s1){
	int mid=j/2,P=s1-j;ll S=0,SS=0;
	S+=(ll)mid*(s0-i+1)+(ll)(j-mid)*(s0-i+1);
	SS+=(ll)mid*(s1-mid)+(ll)(j-mid)*(s1-(j-mid));
	mid=P/(s0/i-1);int sb=P-(s0/i-1)*mid,sa=(s0/i-1)-sb;
	S+=(ll)sa*mid*(s0-2*i+2)+(ll)sb*(mid+1)*(s0-2*i+2);
	SS+=(ll)sa*mid*(s1-mid)+(ll)sb*(mid+1)*(s1-(mid+1));
	return S+SS/2;
}
void solve(){
	for(int i=l;i<=r;i++){
		if(i==0||m==1){res^=pw[i]*((ll)(n+1)*n/2%mod)%mod;continue;}
		int s0=Sum[i-1],s1,sum=0;
		s1=n-s0;sum=((ll)s0*(s0+1)/2-((2ll*s0-i+2)*(i-1)/2))%mod;
		if(s0/i>1){
			int x=2*i,qqq=s1-2*i;
			x+=qqq/(s0/i+1)*2;
			if(s1<2*i)x=s1;
			sum=(sum+calc(i,x,s0,s1))%mod;
			printf("%d",sum);
		}else {
			int mid=s1/2;ll S=0,SS=0;
			S+=(ll)mid*(s0-i+1);
			SS+=(ll)mid*(s1-mid);
			S+=(ll)(s1-mid)*(s0-i+1);
			SS+=(ll)(s1-mid)*(s1-(s1-mid));
			sum=(sum+S+SS/2)%mod;
		}
		res^=((ll)pw[i]*sum%mod);
	}
	printf("%d\n",res);
}
int main(){
	scanf("%d%d%d%d",&m,&l,&r,&X);
	scanf("%s",s);pw[0]=1;
	for(int i=1;i<=m;i++)
		pw[i]=(ll)pw[i-1]*233%mod;
	Sum[0]=X+s[0]-'0';
	for(int i=1;i<m;i++)
		Sum[i]=Sum[i-1]+X+s[i]-'0';
	n=X*m;
	for(int i=0;i<m;i++)n+=s[i]-'0';
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3636kb

input:

2 0 2 2
01

output:

1210541257

result:

wrong answer 1st numbers differ - expected: '541257', found: '1210541257'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #14:

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

input:

2 0 1 114514
10

output:

272788243934764137

result:

wrong answer 1st numbers differ - expected: '934764137', found: '272788243934764137'

Subtask #5:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 9ms
memory: 12252kb

input:

1000000 1000000 1000000 928
01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...

output:

375898332437299311

result:

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

Subtask #6:

score: 10
Accepted

Test #19:

score: 10
Accepted
time: 24ms
memory: 12460kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

852768823

result:

ok 1 number(s): "852768823"

Test #20:

score: 0
Accepted
time: 14ms
memory: 12464kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

852768823

result:

ok 1 number(s): "852768823"

Subtask #7:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 11ms
memory: 12276kb

input:

1000000 0 9823 627
01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...

output:

592990889965734414340234213712978992864808424582276728299751292044780635762267749489753153234801306962299256973679144248784081424031318774906056050199093325554730676617567852178352033665424789730796547219170060982542818928915577501290092348661852972353698704081309517798934561544114385261751978979395...

result:

wrong output format Expected integer, but "592990889965734414340234213712...4178109140444487042510383638431" found

Subtask #8:

score: 0
Skipped

Dependency #1:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%