QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#711272 | #4782. 完美的旅行 | NineSuns | 15 | 334ms | 3968kb | C++14 | 1.7kb | 2024-11-05 08:37:11 | 2024-11-05 08:37:12 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 64, M = 10005, mod = 998244353;
int n, m, a[N][N], ans[N][M];
struct mat {
int a[N][N];
void clr () { for (int i = 0;i < n;i++) for (int j = 0;j < n;j++) a[i][j] = 0; }
void init () {
clr();
for (int i = 0;i < n;i++) a[i][i] = 1;
}
friend mat operator * (const mat & a, const mat & b) {
mat c; c.clr();
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++) {
for (int z = 0;z < n;z++) (c.a[i][j] += (1ll*a.a[i][z]*b.a[z][j]%mod)) %= mod;
}
}
return c;
}
};
void solve () {
cin >> n >> m;
for (int i = 0;i < n;i++) for (int j = 0;j < n;j++) cin >> a[i][j];
int V = 0;
for (int i = n-1;i >= 0;i--) {
vector <int> td;
for (int j = 0;j < n;j++) {
if ((i&j) == i) td.pb(j);
}
mat d; d.clr();
for (int j = 0;j < n;j++) {
for (int z = 0;z < n;z++) d.a[j][z] = a[j][z];
}
mat res; res.init();
for (int j = 1;j <= m;j++) {
res = res*d;
for (int x : td) {
for (int y : td) (ans[i][j] += res.a[x][y]) %= mod;
}
for (int x : td) (res.a[x][x] += ans[i][j]) %= mod;
}
for (int j : td) {
if (j == i) continue;
for (int z = 1;z <= m;z++) {
ans[i][z] -= ans[j][z];
ans[i][z] %= mod;
}
}
for (int z = 1;z <= m;z++) {
ans[i][z] = (ans[i][z]+mod)%mod;
// cout << i << " " << z << " " << ans[i][z] << endl;
V ^= ans[i][z];
}
}
cout << V;
}
signed main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T = 1;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 1ms
memory: 3752kb
input:
4 20 53674686 128460215 363694167 120271218 578912024 941426068 993595265 587468617 731649477 694107878 355552389 226535630 99325151 243772822 66420647 578481511
output:
588479706
result:
ok 1 number(s): "588479706"
Test #2:
score: 15
Accepted
time: 334ms
memory: 3896kb
input:
16 2000 315391385 70546806 184749201 528239002 741286788 146241680 165603053 41114445 572984599 227056916 305263327 980588113 367160763 155832001 212041467 995977944 491801679 569182307 859668874 327536237 778338213 762819679 11238663 728941676 307395331 62905643 662320291 849065607 550529700 282249...
output:
808196376
result:
ok 1 number(s): "808196376"
Test #3:
score: 15
Accepted
time: 1ms
memory: 3636kb
input:
8 100 681016308 947980964 71683807 222166989 633911431 994577572 50784856 298319502 40710797 455891003 503120116 503880841 988981490 34455718 806388934 589433205 327802386 18831411 193642391 916990555 375690304 69587142 72759137 6300182 494361154 892873815 205578968 352463324 154675154 301940078 523...
output:
625872426
result:
ok 1 number(s): "625872426"
Test #4:
score: 15
Accepted
time: 2ms
memory: 3776kb
input:
8 123 42141734 119453053 338794033 469472517 896943474 997318263 463090940 539752993 498132275 425586204 10331275 799002923 314685843 769975525 214134323 412654359 293167153 22579811 116636410 566990382 581484192 102682042 582694943 865977998 241553124 317584926 931548048 157765288 390446073 1855087...
output:
365380190
result:
ok 1 number(s): "365380190"
Test #5:
score: 15
Accepted
time: 1ms
memory: 3808kb
input:
16 5 157021390 252497011 468873864 892465002 392136945 867902344 634574021 416807938 771790989 545264217 666014055 30318904 997001481 92030626 658131204 234369349 43307846 497204529 460391395 44581806 107577365 871932521 470029953 149175762 27325626 819200707 411063821 891562850 191893364 790514504 ...
output:
85280541
result:
ok 1 number(s): "85280541"
Test #6:
score: 15
Accepted
time: 1ms
memory: 3804kb
input:
16 1 905581565 803883371 222387735 113243327 962846914 170270764 908119897 643672711 951948550 443390704 345262472 285268917 716661556 492805236 516049466 646586240 717205802 712046214 204789431 592343665 608834746 958679690 85385338 156417764 101326890 777140727 427162035 294565259 28802739 8285324...
output:
17305742
result:
ok 1 number(s): "17305742"
Test #7:
score: 15
Accepted
time: 315ms
memory: 3856kb
input:
16 1889 291592828 902768692 198687222 265645285 254788066 848949408 683064381 678157787 474168528 862103895 415053306 909831425 935938735 21752343 43155905 228914827 364068446 273045932 507519451 796711939 166902447 72879739 611394755 843648198 3964648 56114938 95672745 864116356 549815108 867090999...
output:
1000245565
result:
ok 1 number(s): "1000245565"
Test #8:
score: 15
Accepted
time: 257ms
memory: 3884kb
input:
16 1538 462407755 549251277 397837861 275994586 415476819 756356324 34904944 520197632 412094442 727727503 875452091 754767133 581156730 826224521 313192343 54965862 57572067 254043810 294905166 657621093 929264117 362049084 974381916 63383415 506826999 577114576 490305008 452699725 907812132 906157...
output:
141964726
result:
ok 1 number(s): "141964726"
Test #9:
score: 15
Accepted
time: 206ms
memory: 3968kb
input:
16 1234 344382827 816941878 819839652 144225696 371171347 966266104 884665589 169825013 765791827 40228758 652684236 893817865 725991829 758836428 252384190 124837650 871491255 654941544 640590098 175202200 748370570 752347597 100539461 38637304 762795606 419148404 537316998 134122726 29051987 94573...
output:
19530996
result:
ok 1 number(s): "19530996"
Test #10:
score: 15
Accepted
time: 334ms
memory: 3856kb
input:
16 1999 12949977 632196974 390885234 944145973 121838884 405002460 237547721 700781753 461518861 947091309 820524334 253274565 296734976 893264350 934506037 438497421 658309595 402128381 470963494 423098778 698061936 170098990 137416574 542917450 696307461 580493544 236741484 982061646 908169428 985...
output:
162533703
result:
ok 1 number(s): "162533703"
Subtask #2:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #11:
score: 15
Accepted
time: 3ms
memory: 3708kb
input:
16 15 314601745 720760464 91785724 114888585 26836821 376536402 313090153 826230415 346734724 333924807 863460032 368340108 245372320 36392298 788713548 515760462 298875827 24627338 31898175 284907313 548032583 57534741 75385967 913412369 336300896 498149570 737179693 974479561 859718707 297256598 3...
output:
407303714
result:
ok 1 number(s): "407303714"
Test #12:
score: 0
Time Limit Exceeded
input:
32 10000 761517608 533611175 252111851 40247028 679296910 479128630 648063750 922719043 15905318 450067426 673017960 429004044 149250097 455699505 781122302 247622532 8960746 139853274 715899414 341830718 10123661 958972771 98773785 523065821 813633478 25481882 318862349 244623710 119270736 59145995...
output:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
16 20000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 4 5 6 7 0 1 2 3 12 13 14 15 8 9 10 11 5 4 7 6 1 0 3 2 13 12 15 14 9 8 11 10 6 7 4 5 2 3 0 1 14 15 12 13 10 11 8 9 7 6 5 4 3 2 1 0 15 14 13 ...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%