QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#400458 | #4900. 数列重排 | Butanlishi | 30 | 14ms | 26832kb | C++14 | 2.1kb | 2024-04-27 11:59:30 | 2024-04-27 11:59:31 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define rg int
#define ci const int
#define ls x<<1
#define rs x<<1|1
#define mid ((l+r)>>1)
#define ld long double
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
#define fd(i,l,r) for(int i=(l);i>=(r);--i)
#define fu(i,l,r) for(int i=(l);i<(r);++i)
#define gcd __gcd
#define P(x) __builtin_popcountll(x)
using namespace std;
ci N=2e5+5,M=1e7+5,mod=998244353,_g=3,_ig=(mod+1)/3;
ll ksm(ll a,ll b=mod-2)
{
ll ans=1;
while(b)
{
if(b&1)ans=(ll)ans*a%mod;
a=(ll)a*a%mod,b>>=1;
}
return ans;
}
const ld eps=1e-10;
inline ll read(){ll u,f=1;char o;while((o=getchar())<48||o>57)if(o==45)f=-1;u=(o^48);while((o=getchar())>=48&&o<=57)u=(u<<1)+(u<<3)+(o^48);return u*f;}
void write(ll x){if(x<0)putchar(45),x=-x;if(x>9)write(x/10);putchar(x%10+48);}
mt19937 rad(chrono::steady_clock::now().time_since_epoch().count());
ll n,m,l,r,k,x,s,a[M],f[M];
ll w[N];
char ch[M];
bool t[N];
void dg(int x)
{
if(x>s)
{
fo(k,0,m)
{
ll p=0;
fo(i,1,s)
{
ll o=0;
fo(i,0,m-1)t[i]=0;
fo(j,i,s)
{
t[w[j]]=1;
while(t[o])++o;
if(o>=k)++p;
}
}
f[k]=max(f[k],p);
}
return;
}
fo(i,1,m)if(a[i])
{
a[i]--;
w[x]=i-1;
dg(x+1);
a[i]++;
}
}
int main()
{//freopen("1.in","r",stdin);
// freopen("mex.in","r",stdin);
// freopen("mex.out","w",stdout);
int T=1;
while(T--)
{
m=read(),l=read(),r=read(),x=read();
scanf("%s",ch+1);
fo(i,1,m)
{
a[i]=x;s+=x;
if(ch[i]=='1')a[i]++,s++;
}
if(m<=2&&l==0&&r==1)
{
f[0]=(s*(s+1)/2)%mod;
f[1]=(f[0]-a[2]+mod)%mod;
}
else
{
if(x==1&&s==m)
{//cout<<"we";
f[0]=(s*(s+1)/2)%mod;
fo(i,1,m)
{
ll o=m-i;
f[i]=(o/2+1)*(o-o/2+1)%mod;
}
}
else
{
s%=mod;
if(m==l&&m==r)
{//cout<<'q';
f[m]=(s*(s+1)/2)%mod;
fo(i,1,m-1)f[m]=(f[m]-(s-i+1)+mod)%mod;
}
else dg(1);
}
}
ll ans=0,u=ksm(233,l);
fo(i,l,r)
{
ans^=(u*f[i]%mod);
u=u*233%mod;
}
cout<<ans<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 7904kb
input:
2 0 2 2 01
output:
541257
result:
ok 1 number(s): "541257"
Test #2:
score: 0
Accepted
time: 2ms
memory: 10076kb
input:
4 1 4 2 00001
output:
525797597
result:
ok 1 number(s): "525797597"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7868kb
input:
9 0 9 1 000000000
output:
711136343
result:
ok 1 number(s): "711136343"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7732kb
input:
1 0 1 9 0
output:
10456
result:
ok 1 number(s): "10456"
Test #5:
score: 0
Accepted
time: 0ms
memory: 8012kb
input:
2 1 2 3 11
output:
1518844
result:
ok 1 number(s): "1518844"
Subtask #2:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #6:
score: 0
Time Limit Exceeded
input:
21 0 21 9 111010011100100100000
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 5
Accepted
Test #14:
score: 5
Accepted
time: 0ms
memory: 8024kb
input:
2 0 1 114514 10
output:
934764137
result:
ok 1 number(s): "934764137"
Test #15:
score: 0
Accepted
time: 1ms
memory: 7948kb
input:
2 0 1 1919810 01
output:
685371514
result:
ok 1 number(s): "685371514"
Test #16:
score: 0
Accepted
time: 1ms
memory: 7932kb
input:
2 0 1 500000000 00
output:
318651831
result:
ok 1 number(s): "318651831"
Subtask #5:
score: 10
Accepted
Test #17:
score: 10
Accepted
time: 11ms
memory: 18560kb
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
437299311
result:
ok 1 number(s): "437299311"
Test #18:
score: 0
Accepted
time: 0ms
memory: 7952kb
input:
100 100 100 10000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
output:
119118463
result:
ok 1 number(s): "119118463"
Subtask #6:
score: 10
Accepted
Test #19:
score: 10
Accepted
time: 10ms
memory: 26728kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
852768823
result:
ok 1 number(s): "852768823"
Test #20:
score: 0
Accepted
time: 14ms
memory: 26832kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
852768823
result:
ok 1 number(s): "852768823"
Subtask #7:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
result:
Subtask #8:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%