QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293036#5825. 矩阵Adp_D100 ✓1293ms210168kbC++141.1kb2023-12-28 20:32:402023-12-28 20:32:40

Judging History

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

  • [2023-12-28 20:32:40]
  • 评测
  • 测评结果:100
  • 用时:1293ms
  • 内存:210168kb
  • [2023-12-28 20:32:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define RI register int
inline int read() {
    RI x=0, w=0;register char ch=0;
    while(!isdigit(ch)) w|=ch=='-', ch=getchar();
    while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
    return w?-x:x;
}
mt19937 rnd(time(0));
const int MAXN=3001, MOD=998244353; int N; 
struct Matrix {
	int a[MAXN][MAXN];
	inline void clear() { for(RI i=1;i<=N;i++) for(RI j=1;j<=N;j++) a[i][j]=0; }
	inline void input() {
		for(RI i=1;i<=N;i++)
			for(RI j=1;j<=N;j++) a[i][j]=read(); 
	}
	inline Matrix operator * (Matrix b) {
		Matrix ret; ret.clear(); 
		for(RI i=1;i<=N;i++)
			for(RI j=1;j<=N;j++) ret.a[i][1]=(ret.a[i][1]+1ll*a[i][j]*b.a[j][1])%MOD; 
		return ret; 
	}
	inline bool operator == (Matrix b) {
		for(RI i=1;i<=N;i++) if(a[i][1]!=b.a[i][1]) return 0;
		return 1;
	}
} A, B, C, t; 
inline void solve() {
	N=read(); t.clear(); 
	for(RI i=1;i<=N;i++) t.a[i][1]=rnd()%(MOD-1)+1; 
	A.input(), B.input(), C.input();
	puts((A*(B*t))==(C*t)?"Yes":"No"); 
}
signed main() {
//	freopen("a.in","r",stdin); 
	int t=read(); while(t--) solve();
    return 0;
}// May all the beauty be blessed.

详细

Test #1:

score: 10
Accepted
time: 986ms
memory: 144228kb

input:

77
5
310980524 649430325 929726167 322133176 196533101
452124191 763518207 462580246 389109943 258982238
980842752 382992674 892794173 572244127 863057091
124971774 306543135 142770389 191933270 159536107
109591708 788516987 986057559 843265788 373012497
68607783 73771527 80822244 141931517 25629982...

output:

Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
No
No
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes

result:

ok 77 token(s): yes count is 54, no count is 23

Test #2:

score: 10
Accepted
time: 227ms
memory: 144588kb

input:

20
19
300786426 55348523 438467798 718608329 639575511 877480154 131078518 50498458 505652400 70781693 60607235 327377105 962399950 299685377 189021169 768713056 159947767 323830788 939451729
663015053 702349816 47032062 144232075 8590829 314695773 653195451 79047310 190236549 193759597 40824001 648...

output:

Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No

result:

ok 20 token(s): yes count is 15, no count is 5

Test #3:

score: 10
Accepted
time: 334ms
memory: 209548kb

input:

17
1596
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 17 token(s): yes count is 13, no count is 4

Test #4:

score: 10
Accepted
time: 1008ms
memory: 199160kb

input:

67
1434
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

Yes
No
Yes
Yes
Yes
No
No
No
Yes
No
No
No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No

result:

ok 67 token(s): yes count is 45, no count is 22

Test #5:

score: 10
Accepted
time: 833ms
memory: 203292kb

input:

56
1496
827382385 334050842 562523170 64248344 772202392 344227963 962535698 610424680 191764282 201712819 261741289 38707441 723490918 616784554 656880245 541289597 106479168 181789413 983195098 366707435 245960214 738618459 166000436 637820477 108811383 83646606 418099171 704739401 10052747 848798...

output:

Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes

result:

ok 56 token(s): yes count is 40, no count is 16

Test #6:

score: 10
Accepted
time: 483ms
memory: 210168kb

input:

20
1603
91905310 952717462 954485887 678448563 186981847 978898327 338140536 142208894 826264776 31056661 228690801 739960038 636575118 693539178 552731649 447161207 735822147 549896101 448501798 249993628 232603979 651172711 525376001 686066708 334392371 31224732 830607244 501599631 12908074 490182...

output:

Yes
No
Yes
No
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes

result:

ok 20 token(s): yes count is 11, no count is 9

Test #7:

score: 10
Accepted
time: 1293ms
memory: 203636kb

input:

83
1504
312926430 470364934 584087355 865456364 663314460 144864284 86040064 304739271 52110782 189905783 204867442 654669354 700416903 873419055 247798007 336659255 547886460 35701369 50399953 750825612 232240264 279725763 390903577 254078528 123437599 833862824 919919348 664000739 203075130 525566...

output:

Yes
Yes
Yes
Yes
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
No
Yes
No
Yes
...

result:

ok 83 token(s): yes count is 55, no count is 28

Test #8:

score: 10
Accepted
time: 1277ms
memory: 203000kb

input:

92
1491
422064757 810225812 58914901 70234338 273595204 258594523 880518679 942823445 991245948 834057054 985736324 626095263 195913075 708777902 158324260 624966332 989571760 895942048 76442464 377096766 794818118 240859092 475927849 113281577 787350276 276940304 971362517 217702894 867701250 98410...

output:

No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Ye...

result:

ok 92 token(s): yes count is 64, no count is 28

Test #9:

score: 10
Accepted
time: 882ms
memory: 203344kb

input:

58
1499
751071830 198863820 292534250 533580356 205272669 522998611 544079196 862157715 390778805 173487948 2829675 199144838 675250424 278673908 174319522 917235530 482538942 310120418 499417216 744352970 198105466 851050201 324562569 348438015 496335083 992485291 846615552 237913613 805117120 5265...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
No

result:

ok 58 token(s): yes count is 39, no count is 19

Test #10:

score: 10
Accepted
time: 898ms
memory: 204936kb

input:

63
1522
804799017 382423356 136999262 517603642 272623548 81400703 177936492 183644706 811008901 195348189 420358926 621889115 536952352 617681319 415690825 430566736 944543466 941130403 758469932 177203809 35830351 321068848 919341658 612155458 741714933 350499007 364263342 739984562 253160541 1993...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
No
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 63 token(s): yes count is 47, no count is 16

Extra Test:

score: 0
Extra Test Passed