ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#205019 | #3566. T1 | nullptr_qwq | 100 | 361ms | 2856kb | C++11 | 3.1kb | 2024-06-18 21:47:18 | 2024-06-18 21:47:20 |
answer
// Problem: #4069. 「GDKOI-S 2023」异或图
// Contest: LibreOJ
// URL: https://loj.ac/p/4069
// Memory Limit: 1024 MB
// Time Limit: 4000 ms
// Author: nullptr_qwq
//
// Powered by CP Editor (https://cpeditor.org)
// 私は猫です
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define dF(i,a,b) for(int i=(a);i>=(b);i--)
#define wh(lzm) while(lzm--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
using namespace std;
ll read(){
ll x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
return x*f;
}
const int mod=998244353,maxn=500005;
inline int qpow(int x,ll y){
int rt=1;
for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) rt=1ll*rt*x%mod;
return rt;
}
inline void inc(int &x,int y){ x=(x+y>=mod)?(x+y-mod):(x+y); }
inline void dec(int &x,int y){ x=(x>=y)?(x-y):(x+mod-y); }
inline void mul(int &x,int y){ x=1ll*x*y%mod; }
inline int add(int x,int y){ return (x+y>=mod)?(x+y-mod):(x+y); }
inline int sub(int x,int y){ return (x>=y)?(x-y):(x+mod-y); }
inline int prod(int x,int y){ return 1ll*x*y%mod; }
inline void chkmax(int &x,int y){ x=max(x,y); }
inline void chkmin(int &x,int y){ x=min(x,y); }
// inline void chkmax(ll &x,ll y){ x=max(x,y); }
// inline void chkmin(ll &x,ll y){ x=min(x,y); }
inline int mypow(int x,int y,int Mod){
x%=Mod; int rt=1;
for(;y;y>>=1,x=(1ll*x*x)%Mod) if(y&1) rt=(1ll*rt*x)%Mod;
return rt;
}
mt19937 rng(time(0));
inline int rd(int l,int r){ return rng()%(r-l+1)+l; }
// mt19937 eng(std::chrono::steady_clock::now().time_since_epoch().count());
// int rd(int l,int r) { return std::uniform_int_distribution<int>(l,r)(eng); }
namespace combi{
int fac[maxn],ifac[maxn],inv[maxn];
void init(int N){
fac[0]=ifac[0]=inv[0]=1;
F(i,1,N) fac[i]=1ll*fac[i-1]*i%mod;
ifac[N]=qpow(fac[N],mod-2);
dF(i,N-1,1) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
F(i,1,N) inv[i]=1ll*ifac[i]*fac[i-1]%mod;
}
inline int C(int n,int m){
if(m>n||n<0||m<0) return 0;
return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
}
//using namespace combi;
int pre[maxn],f[2][2],g[2][2];
int solve(vector<ll>a){
const int n=a.size();
ll sum=0;
for(ll i:a)sum^=i;
int ans=(sum==0);
dF(p,60,0){
memset(f,0,sizeof f),f[0][0]=1;
const int S=(1ll<<p)%mod;
int fl=0;
F(i,0,n-1){
memset(g,0,sizeof g);
if((a[i]>>p)&1){
fl^=1,a[i]^=(1ll<<p);
F(j,0,1) F(k,0,1) inc(g[j^1][k],1ll*(a[i]+1)%mod*f[j][k]%mod),inc(g[j][k|1],1ll*S*f[j][k]%mod);
}
else F(j,0,1) F(k,0,1) g[j][k]=1ll*(a[i]+1)%mod*f[j][k]%mod;
std::swap(f,g);
}
inc(ans,1ll*f[0][1]*qpow(S,mod-2)%mod);
if(fl)break;
}
return ans;
}
void solve(){
}
signed main(){
int n=read();
vector<ll>vec;
F(i,1,n)vec.pb(read());
cout<<solve(vec);
}
Details
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 1224kb
input:
10 3 5 0 1 0 3 5 4 2 5
output:
13248
result:
ok 1 number(s): "13248"
Subtask #2:
score: 10
Accepted
Test #2:
score: 10
Accepted
time: 67ms
memory: 2852kb
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: 66ms
memory: 2852kb
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: 40ms
memory: 2856kb
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: 45ms
memory: 2856kb
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: 44ms
memory: 2856kb
input:
100000 999980995 341927799 474797020 355936070 215296904 77682610 413850993 194378088 233473841 3566...
output:
99729538
result:
ok 1 number(s): "99729538"
Subtask #7:
score: 10
Accepted
Test #7:
score: 10
Accepted
time: 0ms
memory: 1264kb
input:
2000 540706819 309629779 17707890 194083691 334726587 456162964 498417390 246765617 957682339 604730...
output:
800177499
result:
ok 1 number(s): "800177499"
Subtask #8:
score: 10
Accepted
Test #8:
score: 10
Accepted
time: 2ms
memory: 1264kb
input:
2000 101722906 988313572 550840902 777765553 778991206 95817204 989809443 357040014 425595004 794587...
output:
443206431
result:
ok 1 number(s): "443206431"
Subtask #9:
score: 10
Accepted
Test #9:
score: 10
Accepted
time: 50ms
memory: 2852kb
input:
100000 327468559 836395032 98737045 14714567 147268924 355455125 829199457 117664948 79547712 117935...
output:
252529800
result:
ok 1 number(s): "252529800"
Subtask #10:
score: 10
Accepted
Test #10:
score: 10
Accepted
time: 47ms
memory: 2856kb
input:
100000 334373908 573410989 584461609 757523993 595819683 93095595 866600961 552146722 657326632 1804...
output:
633437866
result:
ok 1 number(s): "633437866"