QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88434 | #5827. 异或图 | myee | 30 | 340ms | 10672kb | C++11 | 4.3kb | 2023-03-16 11:09:22 | 2023-03-16 11:09:25 |
Judging History
answer
// 传统计数强省的 998244353 震撼
// 异或卷积呐。
// 集合幂级数呐。
#include <bits/stdc++.h>
typedef unsigned uint;
typedef unsigned long long ullt;typedef long long llt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _min(T&a,T b){return b<a?(a=b,true):false;}
template<typename T>bol _max(T&a,T b){return a<b?(a=b,true):false;}
const ullt Mod=998244353;
using modvec=std::vector<ullt>;
using vec=std::vector<std::pair<bol,ullt> >;
const ullt Lim=1llu<<60;
const uint Bit=60;
ullt Len[Bit+5];
vec get(ullt r){
vec Ans(Bit+1);
for(uint i=0;i<Bit;i++)if(r>=Len[i])Ans[i]={0,1},r-=Len[i];else Ans[i]={1,0};
Ans[Bit]={0,r?1:0};
return Ans;
}
vec mul(vec A,vec B){
modvec UserA(Bit+1),UserB(Bit+1);
for(uint i=0;i<=Bit;i++)UserA[i]=A[i].second*(Len[i]%Mod)%Mod,UserB[i]=B[i].second*(Len[i]%Mod)%Mod;
for(uint i=Bit;i;i--)UserA[i-1]=(UserA[i-1]+UserA[i])%Mod,UserB[i-1]=(UserB[i-1]+UserB[i])%Mod;
vec Ans(Bit+1);
ullt v=0;
for(uint i=0;i<Bit;i++){
Ans[i]={A[i].first==B[i].first,(A[i].second*UserB[i+1]+B[i].second*UserA[i+1]+v)%Mod};
v+=A[i].second*B[i].second%Mod*(Len[i]%Mod)%Mod;
}
Ans[Bit]={0,(A[Bit].second*B[Bit].second+v)%Mod};
return Ans;
}
ullt query(vec A,ullt p){
for(uint i=0;i<Bit;i++)if((p>=Len[i])==A[i].first)return A[i].second;else if(p>=Len[i])p-=Len[i];
return A[Bit].second;
}
ullt A[25],c;
uint E[25],Log2[1u<<15|1],Pop2[1u<<15|1];
ullt Dp[1u<<15|1],Dp2[1u<<15|1];
inline uint lowbit(uint v){return v&-v;}
ullt T[15][16][1u<<15|1],User[1u<<15|1];
ullt Q[16][1u<<15|1],G[1u<<15|1],W[1u<<15|1];
int main()
{
#ifdef MYEE
freopen("QAQ.in","r",stdin);
freopen("QAQ.out","w",stdout);
#else
#endif
Len[Bit]=1;for(uint i=0;i<Bit;i++)Len[i]=Lim>>(i+1);
uint n,m;scanf("%u%u%llu",&n,&m,&c);
{
static uint P[25];for(uint i=0;i<n;i++)scanf("%llu",A+i),P[i]=i,A[i]++;
std::sort(P,P+n,[&](uint a,uint b){return A[a]<A[b];}),std::sort(A,A+n);
std::vector<uint>User(n);for(uint i=0;i<n;i++)User[P[i]]=i;
for(uint i=0,u,v;i<m;i++)scanf("%u%u",&u,&v),u=User[u-1],v=User[v-1],E[u]|=1u<<v,E[v]|=1u<<u;
}
if(!m){
vec a=get(1);for(uint i=0;i<n;i++)a=mul(a,get(A[i]));
printf("%llu\n",query(a,c));return 0;
}
for(uint i=0;i<=n;i++)Log2[1u<<i]=i;
for(uint i=0;i<(1u<<n);i++){
bol ok=1;for(uint j=0;j<n;j++)if(i>>j&1)ok&=!(i&E[j]);
if(ok&&i)Dp[i]=1;
Dp2[i]=Dp[i];
for(uint j=(i-1)&i;j;j=(j-1)&i)if(lowbit(j)==lowbit(i)&&Dp[i^j])Dp2[i]+=Mod-Dp2[j];
Dp2[i]%=Mod;
Pop2[i]=Pop2[i>>1]+(i&1);
if(Pop2[i]&1)T[Log2[lowbit(i)]][Pop2[i]-1][i^lowbit(i)]=Dp2[i];
else User[i]=Dp2[i]*(A[Log2[lowbit(i)]]%Mod)%Mod;
}
for(uint i=0;i<n;i++)for(uint j=0;j<n-i;j++){
for(uint k=i+1;k<n;k++)for(uint l=0;l<(1u<<n);l+=1u<<(i+1))if(l>>k&1)
T[i][j][l]+=T[i][j][l^(1u<<k)];
for(uint l=0;l<(1u<<n);l+=1u<<(i+1))T[i][j][l]%=Mod;
}
ullt ans=0;
for(uint i=0;i<(1u<<n);i++){
vec a=get(1);
for(uint j=0;j<n;j++)if(i>>j&1)a=mul(a,get(A[j]));
G[i]=query(a,c);
}
W[0]=1;
for(uint i=1;i<(1u<<n);i++)for(uint j=i;j;j=(j-1)&i)if(lowbit(i)==lowbit(j))
W[i]=(W[i]+W[i^j]*User[j])%Mod;
for(uint i=0;i<(1u<<n);i++){
uint t=(1u<<n)-i-1;
uint cnt=Pop2[t];
Q[0][0]=1;for(uint k=1;k<=cnt;k++)Q[k][0]=0;
for(uint p=n-1,w=0;~p;p--)if(i>>p&1){
for(uint j=w;;j=(j-1)&w){
for(uint k=cnt;~k;k--)for(uint q=1;q<=k&&p+q<n;q++)Q[k][j]+=T[p][q][j]*Q[k-q][j];
for(uint k=0;k<=cnt;k++)Q[k][j]%=Mod;
if(!j)break;
}
}else{
for(uint j=w;;j=(j-1)&w){
for(uint k=0;k<=cnt;k++)Q[k][j^(1u<<p)]=Q[k][j];
if(!j)break;
}
w|=1u<<p;
}
for(uint k=0;k<=cnt;k++)for(uint a=0;a<n;a++)if(t>>a&1)
for(uint j=t;j;j=(j-1)&t)if(j>>a&1)Q[k][j]+=Mod-Q[k][j^(1u<<a)];
ullt wil=0;
for(uint j=t;~j;j=j-1)j&=t,wil+=W[j^t]*(Q[Pop2[j]][j]%Mod)%Mod;
ans+=wil%Mod*G[i]%Mod;
}
ans%=Mod;
printf("%llu\n",ans);
return 0;
}
// g++ graph.cpp -o graph -std=c++11 -DMYEE -Wall
详细
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 2ms
memory: 3784kb
input:
4 6 2 7 11 14 0 1 2 1 3 2 3 2 4 4 1 4 3
output:
44
result:
ok 1 number(s): "44"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3752kb
input:
4 4 6 12 14 14 5 4 2 1 4 3 2 1 2
output:
798
result:
ok 1 number(s): "798"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3812kb
input:
3 3 2 10 4 11 2 1 3 2 1 3
output:
33
result:
ok 1 number(s): "33"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
4 0 4 9 8 5 2
output:
148
result:
ok 1 number(s): "148"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
5 6 14 12 15 13 13 12 3 1 2 4 2 5 2 1 5 3 4 5
output:
21337
result:
ok 1 number(s): "21337"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
4 5 5 5 2 4 13 2 1 3 4 1 4 4 2 3 2
output:
42
result:
ok 1 number(s): "42"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
4 4 3 13 7 8 12 4 1 3 1 2 4 4 3
output:
552
result:
ok 1 number(s): "552"
Test #8:
score: 0
Accepted
time: 2ms
memory: 3752kb
input:
4 2 12 1 12 4 11 2 1 3 1
output:
70
result:
ok 1 number(s): "70"
Test #9:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
5 5 6 10 7 8 2 13 1 5 1 3 2 1 4 3 5 3
output:
1231
result:
ok 1 number(s): "1231"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
5 7 9 6 7 13 15 12 1 3 5 3 5 2 4 5 4 3 4 1 3 2
output:
6223
result:
ok 1 number(s): "6223"
Test #11:
score: 0
Accepted
time: 2ms
memory: 3644kb
input:
3 0 3 15 7 12
output:
104
result:
ok 1 number(s): "104"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3596kb
input:
3 2 9 10 6 5 1 2 1 3
output:
17
result:
ok 1 number(s): "17"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3776kb
input:
5 5 11 7 9 15 9 9 5 4 5 1 5 2 1 3 3 4
output:
5224
result:
ok 1 number(s): "5224"
Test #14:
score: 0
Accepted
time: 2ms
memory: 3744kb
input:
5 0 12 9 8 14 11 2
output:
3006
result:
ok 1 number(s): "3006"
Test #15:
score: 0
Accepted
time: 2ms
memory: 3664kb
input:
3 1 1 6 10 4 3 1
output:
30
result:
ok 1 number(s): "30"
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #16:
score: 50
Accepted
time: 2ms
memory: 4056kb
input:
9 27 705410105529944560 929827299070190972 733413770730537329 473007347105710981 190062421504120247 918561152768663129 196040702922254016 981530663192980241 203295856357272834 337150461958783092 2 8 7 9 8 9 2 3 9 2 2 7 9 5 9 4 4 8 1 7 6 3 6 1 4 1 6 5 2 4 2 1 9 3 9 6 7 3 7 5 5 2 4 5 2 6 3 1 3 8 4 3 8 6
output:
5392583
result:
ok 1 number(s): "5392583"
Test #17:
score: 0
Accepted
time: 3ms
memory: 4128kb
input:
9 7 788762650337246371 605340092851479114 625896945107761227 361131331380167081 572133549445050458 929899192003968010 340514051531987427 690728985364969400 268762741220048006 818120252827139346 5 8 9 6 6 1 1 9 9 8 5 1 4 5
output:
35237078
result:
ok 1 number(s): "35237078"
Test #18:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
7 8 968166787047166534 945734997493219809 465616677643913237 530128109571749460 717120283671096308 118646732725835921 510958884109370001 797022604947155276 5 2 4 7 1 2 6 5 4 2 4 6 1 6 6 3
output:
133871438
result:
ok 1 number(s): "133871438"
Test #19:
score: 0
Accepted
time: 101ms
memory: 6980kb
input:
12 21 341964498832651322 422448536649714733 488538974423366199 893293448611252565 879334133559023407 13516625885288091 43377983230712374 263189254162337644 474056776923289355 540904774976211471 103364876621830299 515157013276720499 213857038587555252 12 9 8 3 1 9 1 7 3 1 8 11 11 10 6 10 6 1 10 2 7 9...
output:
296076062
result:
ok 1 number(s): "296076062"
Test #20:
score: 0
Accepted
time: 32ms
memory: 5208kb
input:
11 42 215284372701527433 670445786006000260 969876209382224733 248721347029697734 375741447316879814 840434941395805804 187091598433077755 126574401069916039 764298539206353847 750906714570719526 387387869969339518 713140316419888823 1 10 2 5 1 7 4 11 3 11 2 7 4 5 9 5 1 6 3 4 10 9 11 9 3 7 2 1 8 11 ...
output:
861118590
result:
ok 1 number(s): "861118590"
Test #21:
score: 0
Accepted
time: 2ms
memory: 3748kb
input:
7 20 619868500075052677 653541655679358091 619279335581334164 74945438024390700 772996180610853550 636253173293891586 125935970032544337 454311587629767538 7 3 4 5 6 7 2 7 4 2 5 3 4 6 2 6 7 4 5 7 2 5 6 3 5 1 2 3 3 4 1 7 2 1 1 3 5 6 4 1
output:
396474896
result:
ok 1 number(s): "396474896"
Test #22:
score: 0
Accepted
time: 323ms
memory: 10672kb
input:
13 1 655058659126783551 220930961455414900 363602338013759573 443737606888655227 137555247528320912 492558319379424931 930253239754276705 727679308735300884 787033056632957722 29595553176095069 586820353385061840 342786039873677428 141912073483259823 800159879032310691 4 9
output:
504321097
result:
ok 1 number(s): "504321097"
Test #23:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
8 20 301184670062888420 242892377877643484 3476501038317923 44616426924438256 159029640149965614 908446126450853551 608694214104046729 348038770876101788 993564634039215219 5 7 3 8 3 4 8 5 4 6 7 1 6 7 2 4 7 4 3 6 1 2 8 4 8 1 5 4 7 8 1 6 2 5 3 1 8 2 1 4
output:
4724341
result:
ok 1 number(s): "4724341"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
6 11 392024297517399665 88458611428053942 931089704347713876 2933742226147026 827268679955144802 950336975252592744 47151195847292633 3 5 6 4 5 4 2 3 6 5 5 1 1 4 5 2 2 4 1 3 3 4
output:
708968421
result:
ok 1 number(s): "708968421"
Test #25:
score: 0
Accepted
time: 35ms
memory: 5180kb
input:
11 37 271739451037214460 146061942241336421 138038807419718309 876032468776218591 790840232774594443 931090305572222272 446985261776711380 111295394912463090 788835018487784052 490717555570673932 654796069953431186 30534002965260366 10 6 6 7 4 7 2 5 6 4 2 10 3 4 10 7 2 11 4 9 9 7 6 11 1 11 1 9 9 10 ...
output:
405837840
result:
ok 1 number(s): "405837840"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
7 20 603717808363574959 741883086260303904 498239876637304614 692656406513867207 11452440849146981 847091012107531819 751030904432703677 42306162304440584 7 4 3 5 3 1 7 3 2 1 2 4 7 2 5 6 5 7 4 5 1 6 3 2 1 5 6 3 2 5 3 4 4 6 6 2 7 1 4 1
output:
409098870
result:
ok 1 number(s): "409098870"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
7 14 276788100956613806 955375196371523555 993133468996644095 851781246244565785 406378187351709927 103400146137304775 3339166120945122 878092054213365193 6 5 3 4 6 3 2 7 1 4 6 1 7 6 3 7 4 2 4 6 1 7 1 5 4 7 3 2
output:
424423580
result:
ok 1 number(s): "424423580"
Test #28:
score: 0
Accepted
time: 36ms
memory: 5204kb
input:
11 42 703121070332973172 453838237041390989 7923458002585165 10157854185578313 428694248761966896 99567674522515040 887169792891871053 685704683091155403 1114809813572478 44938950664511738 433569272578015242 743893677718957742 10 2 5 4 7 3 5 9 10 7 6 1 9 7 5 7 8 6 2 5 2 11 1 10 3 5 4 3 4 1 5 11 11 7...
output:
266801727
result:
ok 1 number(s): "266801727"
Test #29:
score: 0
Accepted
time: 6ms
memory: 4164kb
input:
9 30 557579472218086545 389315525875489778 580024732015329877 122856826128791692 353894892064461662 593243941610294518 367724855679451396 93186374563462910 566339146552758642 503166485328553628 1 2 6 4 7 6 7 2 5 7 6 2 7 3 5 1 9 2 5 6 8 3 1 9 2 3 7 4 6 3 7 8 4 5 8 9 9 7 1 7 6 9 1 4 4 3 2 4 2 5 1 6 8 ...
output:
949276406
result:
ok 1 number(s): "949276406"
Test #30:
score: 0
Accepted
time: 3ms
memory: 3780kb
input:
8 3 145845032992032081 128648457003011001 90366745088645729 628278583922604945 949868219248781702 205548014539121837 573918524435421016 330291118265768760 961310581410805998 4 6 8 3 8 5
output:
522900734
result:
ok 1 number(s): "522900734"
Test #31:
score: -50
Wrong Answer
time: 340ms
memory: 10508kb
input:
13 75 122013601152601020 102573945790661441 119801481456740433 918257918904279930 290942994898157004 263309413587975225 176964463128718582 761601089984502811 634241033261747054 571682868717366221 514639207383578779 104093621484438574 329127701356038973 75081873200425743 12 10 8 5 6 8 9 10 3 11 11 7 ...
output:
744155981
result:
wrong answer 1st numbers differ - expected: '692554911', found: '744155981'
Subtask #3:
score: 10
Accepted
Test #47:
score: 10
Accepted
time: 2ms
memory: 3748kb
input:
14 0 731833687287532167 157552918690640051 900457311668526045 111217720157614956 84140984111060473 814012186135880499 784848789620248379 958953377683017264 105083874298571687 104921429970878846 44983041675142735 871013110538758030 686733907990421995 98063590462078176 495161493555059993
output:
231790380
result:
ok 1 number(s): "231790380"
Test #48:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
11 0 101435837408688522 638776638580507479 933944392115323974 19098604312360490 142362319980029593 419910251764515410 275591812677260089 770239593400917018 928344484461634421 67340905784404712 378109786925249078 110881245457449811
output:
242383534
result:
ok 1 number(s): "242383534"
Test #49:
score: 0
Accepted
time: 2ms
memory: 3668kb
input:
9 0 100988561775675251 622570387572403506 684352103903274038 784649864569409753 270298495621205212 56183537059869110 346856482529145989 86639702870530669 607198038565138736 14747634008501988
output:
20893166
result:
ok 1 number(s): "20893166"
Test #50:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
10 0 839910859917247463 611237879350518457 292219463776059962 548211857317940894 822255554598388425 335628456629874391 774414280870858683 882480367082748768 654587410087321403 74330774886125511 22894883233341926
output:
61697734
result:
ok 1 number(s): "61697734"
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%