QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75577#4907. djq 学生物4182_543_731100 ✓689ms10732kbC++2.3kb2023-02-05 20:45:582023-02-05 20:46:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-05 20:46:00]
  • 评测
  • 测评结果:100
  • 用时:689ms
  • 内存:10732kb
  • [2023-02-05 20:45:58]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define N 1680001
#define M 259
#define mod 998244353
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int f[M][M],g[M][M],fg=0;
void getinv(int n)
{
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)g[i][j]=i==j;
	for(int i=0;i<n;i++)
	{
		int fr=-1;
		for(int j=i;j<n;j++)if(f[j][i])fr=j;
		if(fr==-1){fg=1;return;}
		for(int j=0;j<n;j++)swap(f[i][j],f[fr][j]),swap(g[i][j],g[fr][j]);
		int ir=pw(f[i][i],mod-2);
		for(int j=0;j<n;j++)f[i][j]=1ll*f[i][j]*ir%mod,g[i][j]=1ll*g[i][j]*ir%mod;
		for(int j=0;j<n;j++)if(j!=i)
		{
			int tp=mod-f[j][i];
			for(int k=0;k<n;k++)f[j][k]=(f[j][k]+1ll*tp*f[i][k])%mod,g[j][k]=(g[j][k]+1ll*tp*g[i][k])%mod;
		}
	}
}
int n,su,si,vi[N],as;
int trs[6][6]={{1,0,0,1,1,1},{1,0,-1,-1,-1,1},{0,1,1,0,-1,1},{-1,-1,1,0,1,1},{0,1,-1,-1,1,1},{-1,-1,0,1,-1,1}},rtrs[6][6];
void trans(int su,int *f,int tr[][6])
{
	int t1[6],t2[6];
	for(int i=1;i<su;i*=6)
	for(int j=0;j<su;j+=i*6)
	for(int k=0;k<i;k++)
	{
		for(int p=0;p<6;p++)t1[p]=f[j+k+p*i],t2[p]=0;
		for(int p=0;p<6;p++)for(int q=0;q<6;q++)t2[q]=(t2[q]+1ll*t1[p]*tr[p][q])%mod;
		for(int p=0;p<6;p++)f[j+k+p*i]=(t2[p]+mod)%mod;
	}
}
void solve(int n,vector<vector<int> > sr)
{
	int l=sr.size();
	if(!n)
	{
		for(int i=0;i<l;i++)for(int j=0;j<l;j++)f[i][j]=(mod+(i==j)*(si+1)-vi[sr[i][j]])%mod;
		getinv(l);
		for(int i=0;i<l;i++)for(int j=0;j<l;j++)vi[sr[i][j]]=g[i][j];
		return;
	}
	for(int i=0;i<l;i++)for(int j=0;j<l;j++)sr[i][j]=sr[i][j]*6+4;
	solve(n-1,sr);
	for(int i=0;i<l;i++)for(int j=0;j<l;j++)sr[i][j]++;
	solve(n-1,sr);
	vector<vector<int> > nr;
	for(int i=0;i<l;i++)
	{
		vector<int> tp;
		for(int j=0;j<l;j++)tp.push_back(sr[i][j]-5),tp.push_back(sr[i][j]-4);
		nr.push_back(tp);
		for(int j=0;j<l*2;j++)tp[j]+=2;
		nr.push_back(tp);
	}
	solve(n-1,nr);
}
int main()
{
	scanf("%d",&n);
	su=1;for(int i=1;i<=n;i++)su*=6;
	for(int i=0;i<su;i++)scanf("%d",&vi[i]),si=(si+vi[i])%mod;
	trans(su,vi,trs);solve(n,{{0}});
	for(int i=0;i<6;i++)for(int j=0;j<6;j++)f[i][j]=trs[i][j];
	getinv(6);
	for(int i=0;i<6;i++)for(int j=0;j<6;j++)rtrs[i][j]=g[i][j];
	trans(su,vi,rtrs);
	for(int i=0;i<su;i++)as^=vi[i];
	printf("%d\n",fg?-1:as);
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 2ms
memory: 3056kb

input:

1
10 10 10 10 499122217 499122156

output:

-1

result:

ok 1 number(s): "-1"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3000kb

input:

1
719885386 651516139 596516649 191397068 26958009 352245674

output:

320270701

result:

ok 1 number(s): "320270701"

Test #3:

score: 0
Accepted
time: 0ms
memory: 2984kb

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: 3052kb

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: 0
Accepted
time: 1ms
memory: 3036kb

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: 0
Accepted
time: 0ms
memory: 3124kb

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: 0
Accepted
time: 0ms
memory: 3136kb

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: 88ms
memory: 4652kb

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: 0
Accepted
time: 611ms
memory: 10732kb

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: 0
Accepted
time: 650ms
memory: 10728kb

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: 0
Accepted
time: 641ms
memory: 10728kb

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: 3016kb

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: 0
Accepted
time: 2ms
memory: 3164kb

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: 0
Accepted
time: 2ms
memory: 3080kb

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: 4ms
memory: 3156kb

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: 0
Accepted
time: 11ms
memory: 3388kb

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: 0
Accepted
time: 100ms
memory: 4540kb

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: 0
Accepted
time: 663ms
memory: 10724kb

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: 0
Accepted
time: 660ms
memory: 10688kb

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: 0
Accepted
time: 689ms
memory: 10724kb

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