QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290775#4900. 数列重排do_while_true0 0ms0kbC++202.8kb2023-12-25 13:42:112023-12-25 13:42:11

Judging History

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

  • [2023-12-25 13:42:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-12-25 13:42:11]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
	int s=1;
	while(y){
		if(y&1)s=1ll*s*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return s;
}
const int N=10000010;
ll n,m,l,r,c;
int pre[N];
char str[N];
ll dbh(ll l,ll r){
	if(l>r)return 0;
	return (l+r)*(r-l+1);
}
ll solve(ll k){
	if(k==0)return n*(n+1)/2%mod;
	ll ans=(n-k+2)*(n-k+1)/2%mod;
	ll r=n-k*c-pre[k];
	if(k==1){
		int ct=c+1;
		if(pre[k]==k)++ct;
		int cs=r/ct;
		ans-=1ll*dbh(1,1+cs-1)%mod*((mod+1)/2)%mod*ct%mod;
		ans=(ans+mod)%mod;
		r-=cs*ct;
		ans-=r%mod*(1+cs)%mod;
		ans=(ans+mod)%mod;
		return ans;
	}
	ll t=min(2*(k-1),r);
	ans-=dbh(1,t/2)%mod;
	if(t&1)ans-=(1+t/2)%mod;
	ans=(ans+mod)%mod;
	r-=t;
	int ct=c+1;
	if(pre[k]==k)++ct;
	int cs=r/ct;
	ans-=dbh(k,k+cs-1)%mod*((mod+1)/2)%mod*ct%mod;
	ans=(ans+mod)%mod;
	r-=cs*ct;
	ans-=r%mod*(k+cs)%mod;
	ans=(ans+mod)%mod;
	return ans;
}
signed main(){
//	#ifdef do_while_true
		assert(freopen("mex.in","r",stdin));
		assert(freopen("mex.out","w",stdout));
//	#endif
	read(m,l,r,c);
	scanf("%s",str+1);
	n=1ll*m*c;
	for(int i=1;i<=m;i++)pre[i]=pre[i-1]+str[i]-'0';
	n+=pre[m];
	int coef=qpow(233,l),su=0;
	for(int k=l;k<=r;k++){
		int s=solve(k);
//		dbg(s);
		su^=1ll*coef*s%mod;
		coef=coef*233ll%mod;
	}
	cout<<su<<'\n';
    #ifdef do_while_true
//		cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

2 0 2 2
01

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Runtime Error

Test #14:

score: 0
Runtime Error

input:

2 0 1 114514
10

output:


result:


Subtask #5:

score: 0
Runtime Error

Test #17:

score: 0
Runtime Error

input:

1000000 1000000 1000000 928
01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #19:

score: 0
Runtime Error

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #7:

score: 0
Runtime Error

Test #21:

score: 0
Runtime Error

input:

1000000 0 9823 627
01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...

output:


result:


Subtask #8:

score: 0
Skipped

Dependency #1:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%