QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#526451 | #4907. djq 学生物 | liuhengxi | 100 ✓ | 345ms | 21728kb | C++14 | 3.6kb | 2024-08-21 16:08:31 | 2024-08-21 16:08:31 |
Judging History
answer
// created: 2024-08-21 09:29:39
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#define F(i,l,r) for(int i=(l),i##_end=(r);i<i##_end;++i)
#define I128 //||is_same<T,__int128_t>::value||is_same<T,__uint128_t>::value
using namespace std;
template<typename T>enable_if_t<is_integral<T>::value I128,void> readmain(T &x)
{
bool neg=false;int c=getchar();
for(;!isdigit(c);c=getchar())if(c=='-')neg=true;
for(x=0;isdigit(c);c=getchar())x=(T)(10*x+(c-'0'));
if(neg)x=-x;
}
template<typename T>T& read(T &x){readmain(x);return x;}
template<typename T,typename ...Tr>void read(T &x,Tr&... r){readmain(x);read(r...);}
typedef unsigned long long ull;
constexpr int N=8,N6=1679616,NN=1<<8,MOD=998244353,BP=0x55555555;
void reduce(int &x){(x>=MOD)&&(x-=MOD);}
void reduce_(int &x){(x<0)&&(x+=MOD);}
int qpow(ull a,int b,ull c=1)
{
for(;b;b>>=1,(a*=a)%=MOD)if(b&1)(c*=a)%=MOD;
return (int)c;
}
struct s3e
{
int m00,m01,m10,m11,par,id;
constexpr friend s3e operator*(const s3e &u,const s3e &v)
{
return {(int)(((ull)u.m00*v.m00+(ull)u.m01*v.m10)%MOD),(int)(((ull)u.m00*v.m01+(ull)u.m01*v.m11)%MOD),
(int)(((ull)u.m10*v.m00+(ull)u.m11*v.m10)%MOD),(int)(((ull)u.m10*v.m01+(ull)u.m11*v.m11)%MOD),
(int)((ull)u.par*v.par%MOD),(int)((ull)u.id*v.id%MOD)};
}
};
constexpr s3e s3id={1,0,0,1,1,1},s3r={0,1,MOD-1,MOD-1,1,1},s3f={0,1,1,0,MOD-1,1};
constexpr s3e s3[6]={s3id,s3f,s3f*s3r,s3r,s3r*s3r,s3r*s3f};
int tr[6][6],itr[6][6];
void init()
{
static int a[6][6];
F(i,0,6)memcpy(tr[i],&s3[i],sizeof(int)*6),itr[i][i]=1;
F(i,0,6)F(j,0,i)swap(tr[i][j],tr[j][i]);
memcpy(a,tr,sizeof tr);
F(i,0,6)
{
if(!a[i][i])F(j,i+1,6)if(a[j][i])swap(a[i],a[j]),swap(itr[i],itr[j]);
int iv=qpow(a[i][i],MOD-2);
F(j,i,6)a[i][j]=(int)((ull)iv*a[i][j]%MOD);
F(j,0,6)itr[i][j]=(int)((ull)iv*itr[i][j]%MOD);
F(j,0,6)if(j!=i)
{
int c=MOD-a[j][i];
F(k,i,6)a[j][k]=(int)((a[j][k]+(ull)c*a[i][k])%MOD);
F(k,0,6)itr[j][k]=(int)((itr[j][k]+(ull)c*itr[i][k])%MOD);
}
}
}
int n,n6,a[N6],p6[N+1],b[NN][NN],w[N],sw[NN],ib[NN][NN];
ull aa[N6];
int main()
{
init();
read(n);
F(i,p6[0]=1,n+1)p6[i]=p6[i-1]*6;
n6=p6[n];
int sa=1;
F(i,0,n6)reduce(sa+=read(a[i]));
int isa=qpow(sa,MOD-2);
F(i,0,n6)a[i]=(int)((ull)isa*a[i]%MOD);
for(int i=1;i<n6;i*=6)
{
for(int j=0;j<n6;j+=6*i)F(x,0,6)F(y,0,6)F(k,j,j+i)aa[x*i+k]+=(ull)tr[x][y]*a[y*i+k];
F(j,0,n6)a[j]=(int)(aa[j]%MOD),aa[j]=0;
}
F(i,0,1<<(2*n))if(!((~i>>1&i)&BP))
{
int sh=0,d=0;
F(j,0,n)
{
int t=i>>(2*j)&3;
if(t)sh+=p6[j]*(t+2);
else w[d++]=p6[j];
}
reverse(w,w+d);
F(j,1,1<<d)sw[j]=sw[j^(j&-j)]+w[__builtin_ctz(j)];
F(x,0,1<<d)F(y,0,1<<d)b[x][y]=a[sh+2*sw[x]+sw[y]],b[x][y]&&(b[x][y]=MOD-b[x][y]);
F(x,0,1<<d)reduce(++b[x][x]);
F(x,0,1<<d)memset(ib[x],0,sizeof(int)<<d),ib[x][x]=1;
F(x,0,1<<d)
{
if(!b[x][x])F(y,x+1,1<<d)if(b[y][x])swap(b[x],b[y]),swap(ib[x],ib[y]);
if(!b[x][x])return puts("-1"),0;
int iv=qpow(b[x][x],MOD-2);
F(y,x,1<<d)b[x][y]=(int)((ull)iv*b[x][y]%MOD);
F(y,0,1<<d)ib[x][y]=(int)((ull)iv*ib[x][y]%MOD);
F(y,0,1<<d)if(y!=x)
{
int c=MOD-b[y][x];
F(z,x,1<<d)b[y][z]=(int)((b[y][z]+(ull)c*b[x][z])%MOD);
F(z,0,1<<d)ib[y][z]=(int)((ib[y][z]+(ull)c*ib[x][z])%MOD);
}
}
F(x,0,1<<d)F(y,0,1<<d)a[sh+2*sw[x]+sw[y]]=ib[x][y];
}
for(int i=1;i<n6;i*=6)
{
for(int j=0;j<n6;j+=6*i)F(x,0,6)F(y,0,6)F(k,j,j+i)aa[x*i+k]+=(ull)itr[x][y]*a[y*i+k];
F(j,0,n6)a[j]=(int)(aa[j]%MOD),aa[j]=0;
}
F(i,0,n6)a[i]=(int)((ull)isa*a[i]%MOD);
int ans=0;
F(i,0,n6)ans^=a[i];
printf("%d\n",ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3384kb
input:
1 10 10 10 10 499122217 499122156
output:
-1
result:
ok 1 number(s): "-1"
Test #2:
score: 10
Accepted
time: 0ms
memory: 3588kb
input:
1 719885386 651516139 596516649 191397068 26958009 352245674
output:
320270701
result:
ok 1 number(s): "320270701"
Test #3:
score: 10
Accepted
time: 0ms
memory: 3544kb
input:
1 783368690 104275706 48409057 969269573 366936187 542139073
output:
252144401
result:
ok 1 number(s): "252144401"
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #4:
score: 20
Accepted
time: 0ms
memory: 3576kb
input:
2 304089172 305211383 35005211 521595368 294702567 728712076 336465782 861021530 278722862 233665123 148685361 468703135 103269576 803735449 317389669 635723058 370888716 127653814 61717040 92529750 628175011 658233689 132931876 655133020 859484421 916300566 608413784 756898537 736330845 975349971 1...
output:
396724238
result:
ok 1 number(s): "396724238"
Test #5:
score: 20
Accepted
time: 0ms
memory: 3528kb
input:
2 913515603 749241873 137806862 42999170 982906996 135497281 511702305 87932219 939232731 829091974 572660336 160882152 805750846 634377376 102416960 435681504 143371771 84353895 939819582 4611839 2410108 549989014 610515434 587746011 376099690 760313750 478926734 356426808 945117276 891702825 78245...
output:
870050121
result:
ok 1 number(s): "870050121"
Test #6:
score: 20
Accepted
time: 0ms
memory: 3556kb
input:
3 57511226 265850707 413305323 845749015 943947739 985965659 855636226 751454233 471103741 958053186 37896442 463480570 44162728 977716025 317097467 893822248 378465744 927612902 332328964 603570492 689682299 660260756 959997301 485560280 402724286 593209441 196709512 894429689 364228444 949102266 2...
output:
315521842
result:
ok 1 number(s): "315521842"
Test #7:
score: 20
Accepted
time: 0ms
memory: 3524kb
input:
3 349517445 588219756 858424826 59174065 995706887 824845059 66858995 625032172 387451659 471017656 564157983 298625210 296921989 59223234 801633853 557074948 382697713 476667372 72330968 260401255 296864819 774044599 697517721 4741198 952711586 337695458 798829587 758671314 67067352 719346228 84681...
output:
927050034
result:
ok 1 number(s): "927050034"
Subtask #3:
score: 15
Accepted
Test #8:
score: 15
Accepted
time: 37ms
memory: 9212kb
input:
7 13237606 0 0 696947386 879320747 0 0 0 0 0 0 0 0 0 0 0 0 0 266959993 0 0 371358373 632390641 0 666960563 0 0 708812199 564325578 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 299649176 0...
output:
101942575
result:
ok 1 number(s): "101942575"
Test #9:
score: 15
Accepted
time: 312ms
memory: 21672kb
input:
8 114962507 0 0 952617546 783387964 0 0 0 0 0 0 0 0 0 0 0 0 0 950188130 0 0 79845349 400660703 0 865722684 0 0 186015033 757001842 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 563538995 0...
output:
976515923
result:
ok 1 number(s): "976515923"
Test #10:
score: 15
Accepted
time: 314ms
memory: 21708kb
input:
8 125443968 0 0 825927837 967844197 0 0 0 0 0 0 0 0 0 0 0 0 0 128726374 0 0 893763697 934490504 0 811156183 0 0 90656766 98645533 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 858436076 0 ...
output:
660528054
result:
ok 1 number(s): "660528054"
Test #11:
score: 15
Accepted
time: 309ms
memory: 21712kb
input:
8 553951831 0 0 3610932 151003694 0 0 0 0 0 0 0 0 0 0 0 0 0 239318443 0 0 408922789 79644945 0 59445445 0 0 144621393 336045244 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 329064496 0 0 ...
output:
355824768
result:
ok 1 number(s): "355824768"
Subtask #4:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #12:
score: 20
Accepted
time: 0ms
memory: 5628kb
input:
4 887790043 739693399 870246744 301313259 18507681 629005716 67544354 58092673 642897565 70732414 899481125 727551664 871859472 220238086 708355050 385234243 645860416 129326472 850844210 577801468 684900507 461005014 934205121 591855867 526169505 197643478 136123938 67642730 682939149 949635706 281...
output:
602449578
result:
ok 1 number(s): "602449578"
Test #13:
score: 20
Accepted
time: 0ms
memory: 3592kb
input:
4 557598958 113906113 211073291 59019633 110287605 318903034 307171270 201167854 142201998 886457896 24068541 289099056 55884864 35794579 11689085 615385706 684842316 559228752 366244387 646068652 535314708 313739657 846826781 931109365 759018899 574643185 553946098 150095139 137782333 741636661 949...
output:
37335981
result:
ok 1 number(s): "37335981"
Test #14:
score: 20
Accepted
time: 0ms
memory: 3568kb
input:
4 376545129 990894084 275573387 559810624 528344836 360116901 406141975 630960645 550842736 709965265 690253412 98881522 427656896 104902833 504114740 620019063 359704636 908644219 755230881 459810186 435557594 214555147 965394547 449697679 122566226 581267354 68455475 593798485 142522444 164230614 ...
output:
75788971
result:
ok 1 number(s): "75788971"
Subtask #5:
score: 35
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #15:
score: 35
Accepted
time: 1ms
memory: 3532kb
input:
5 927227492 433462495 682484392 792453283 515614277 572882205 869882034 134859027 597519975 814230265 964334366 928235854 270932934 360466938 859244355 704701658 346892037 476472729 774188464 647828172 144729335 72341130 766681749 361690425 376034039 468002144 849139480 955698428 333940200 373129969...
output:
686998100
result:
ok 1 number(s): "686998100"
Test #16:
score: 35
Accepted
time: 7ms
memory: 3908kb
input:
6 385889732 715940941 809320622 760587593 48446951 239838379 284668020 435499616 783637300 661145708 795068133 683289232 266510512 857809122 222215801 224926125 466282573 608613056 185036526 287480814 167824917 97954516 142934563 171158492 770699609 561543368 480089055 586572221 651141452 799987124 ...
output:
756516704
result:
ok 1 number(s): "756516704"
Test #17:
score: 35
Accepted
time: 48ms
memory: 8736kb
input:
7 583414677 13185768 916028761 542120858 174890922 432766097 261428292 687179011 399149458 532692284 358330290 657368988 412309829 754665617 536729693 165455952 22417688 748902222 615463894 882513992 900486064 764721436 220757216 65352706 517273741 256026961 133801752 615488054 822452736 229994169 4...
output:
955317918
result:
ok 1 number(s): "955317918"
Test #18:
score: 35
Accepted
time: 332ms
memory: 21620kb
input:
8 722924649 273219172 349651365 41915785 311046537 705921640 746058964 357806254 718138974 84445040 79595086 251117241 8624872 866367338 408762219 598199999 60640485 115204883 548538809 54077438 212857282 240798456 472239435 239920809 672764634 530778816 863403314 761529500 295233355 398430959 73502...
output:
292468538
result:
ok 1 number(s): "292468538"
Test #19:
score: 35
Accepted
time: 345ms
memory: 21692kb
input:
8 901364377 737641198 390124043 384040299 644146054 200624031 993471282 293435314 103879437 130156485 346617872 283946775 965945085 365263135 121266329 102639256 887945102 157743898 416970183 477347448 24776016 443539767 42416462 737135796 845686455 482442538 541148724 503452456 726958687 561435942 ...
output:
432716847
result:
ok 1 number(s): "432716847"
Test #20:
score: 35
Accepted
time: 340ms
memory: 21728kb
input:
8 545150581 655612063 770584467 64807262 59386893 54096891 24835050 321857897 139160667 36569422 684241896 796854649 149475829 756409627 556478348 822273756 156817397 886061038 342086666 553513252 586949363 979798902 46022878 697210794 908441481 975926648 889488153 79097921 273378779 983155816 34872...
output:
769329621
result:
ok 1 number(s): "769329621"
Extra Test:
score: 0
Extra Test Passed