QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#548253 | #6347. XOR Determinant | BFSDFS123# | TL | 765ms | 44680kb | C++14 | 1.1kb | 2024-09-05 16:36:18 | 2024-09-05 16:36:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
const int Mod=998244353;
const int Maxn=5010;
int qpow(int a,int b=Mod-2)
{
a=(a%Mod+Mod)%Mod;
int res=1;
while(b)
{
if(b&1)
{
res=res*a%Mod;
}
a=a*a%Mod;
b>>=1;
}
return res;
}
int a[Maxn],b[Maxn];
int n;
int C[Maxn][Maxn];
int work()
{
int ans=1;
for(int i=1;i<=n;i++)
{
for(int j=i;j<=n;j++)
{
if(C[j][i])
{
if(j!=i) ans=-ans;
swap(C[i],C[j]);break;
}
}
if(!C[i][i]) return 0;
int inv=qpow(C[i][i]);
for(int j=i+1;j<=n;j++)
{
int t=inv*C[j][i]%Mod;
for(int k=i;k<=n;k++)
{
C[j][k]=(C[j][k]-t*C[i][k])%Mod;
}
}
ans=ans*C[i][i]%Mod;
}
return (ans%Mod+Mod)%Mod;
}
void solve()
{
scanf("%lld",&n);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
C[i][j]=a[i]^b[j],C[i][j]%=Mod;
// if(n>61) puts("0");
// else
printf("%lld\n",work());
}
signed main()
{
int T;
scanf("%lld",&T);
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4128kb
input:
3 2 2 5 4 1 1 1000000000000000001 987467354324283836 4 1 2 3 4 1 2 3 4
output:
21 214139910 998244129
result:
ok 3 number(s): "21 214139910 998244129"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
1 5 1 2 3 4 5 1 2 3 4 5
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4316kb
input:
100 10 1107560013855173757 966681903163989710 521892103913129269 1038348664970462356 604430971757857481 1106581500345020431 788162934600883665 124672524392773463 534904853987097709 784497626701360420 402515001559379490 846591944896429860 761680713769800085 722846292535048189 621369111578909792 49581...
output:
548320033 488137899 509538360 732652365 956551480 888843023 560651618 189658616 667887492 788885505 155196573 934158515 897579513 928218896 846866262 443345610 390799518 148725345 892245870 273938687 487734460 478338536 258981818 853512398 952636045 406224138 199504048 631337716 29490784 62730160 94...
result:
ok 100 numbers
Test #4:
score: 0
Accepted
time: 42ms
memory: 7276kb
input:
181 55 259826570151423127 58870406144128000 310271049587997524 401710073886773698 514286909385841735 162284846714225243 536074036455895273 265892726370365687 1083624247485293743 2294265759278634 1109697269509916767 119509764279027081 676809147172263541 685533985118893838 578164705093722225 749670267...
output:
250966714 189614849 870870263 628983732 439500925 167026357 880398758 988810735 911943102 1063939 834869831 322770187 318884496 313423629 256256099 557682540 821588970 365649865 728030647 227507483 54912370 697674469 17837535 608934788 198096034 862343012 611724164 461668994 190235391 3648045 303758...
result:
ok 181 numbers
Test #5:
score: 0
Accepted
time: 49ms
memory: 7664kb
input:
169 59 263131534273822231 721315260374372529 22596975172294779 587943029601145634 578406889381301720 1052976625790254378 1042479356926816953 62521207877861669 84439288007663497 104844738588741000 1114460585099051870 114694613171354451 737641966677819022 428614303859254465 736738606337870847 10270405...
output:
679833894 707359193 489328896 489331972 378698263 670232661 604105888 337180462 768492368 287273997 416687126 531928536 497729522 781926730 637316876 448456159 839190068 52762183 584682392 634497786 902597867 971239442 361789519 331227756 191954243 240205925 234462528 495375269 592860446 207834359 8...
result:
ok 169 numbers
Test #6:
score: 0
Accepted
time: 49ms
memory: 6348kb
input:
166 60 80154134565266370 488932265115032860 303835835035297206 575581085106658104 833807689536921183 187169890408130963 1048058980828122057 110567463708412924 327808012109170094 95218974667774735 433999115170249685 467678946339214050 609742608869014608 133569764370459119 776300965852048567 463747864...
output:
670693684 567395563 608098032 942216233 217410998 326969104 25422274 480790118 342481245 102562285 61647851 552914906 620545717 914965321 3734736 105108911 696719302 651957753 613434616 624957763 426547790 885982943 586546938 104962862 114875102 677394436 60012578 348000979 692703882 977900715 85838...
result:
ok 166 numbers
Test #7:
score: 0
Accepted
time: 49ms
memory: 6436kb
input:
163 61 80980377743349794 78082725295428680 808378069808536832 277850281918593630 877981892336811364 898303075033883084 323880166130506137 525399171051596912 366242148391474277 120856593948882151 723420323440470677 764275661616196241 647981809066855810 259339928715802532 1105675893907201571 986085105...
output:
781999390 150921221 900235323 20064573 694343886 190286225 449935087 616624976 39538288 98442178 774594670 603521139 10351203 463784420 333056108 882021489 788229234 168165928 207073662 923993026 73715002 601966927 335770037 491758974 130974448 495077297 687620817 975466541 141059536 870777248 69416...
result:
ok 163 numbers
Test #8:
score: 0
Accepted
time: 49ms
memory: 8060kb
input:
161 62 81806616626465922 820154690082671476 159998799974929481 1133040983337376131 922156095136701546 752622856039737192 940230878394780900 876189860964965406 404676288968745755 146494213229989566 1012841527415724372 53450261428508183 918808710068410578 9472340566470933 895300396186403473 5946824184...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 161 numbers
Test #9:
score: 0
Accepted
time: 46ms
memory: 6440kb
input:
181 55 813902528530498317 180553376450447066 952929383886454990 1127838565189677747 462303537504172717 166170016407693079 41709138539484009 120616734935102105 773550734702549860 652558168256903871 822608206166062912 344962306047843251 653626998063283215 539367306208685872 1073092847699637600 1075409...
output:
533150857 223914787 76208125 879575230 684211869 489973789 363840325 385273972 683382412 754906630 723304744 891645742 840183276 857914697 465043418 273457101 599333673 289388109 36603890 188185515 711040291 251963599 164600864 248651956 320282448 799695992 514398894 743707838 241657476 423674013 85...
result:
ok 181 numbers
Test #10:
score: 0
Accepted
time: 45ms
memory: 7396kb
input:
169 59 664633971924301509 1015856842210128652 1135439982029079939 664938483297163839 969041681867477622 503817547941989704 1120582593358942609 512315393524375922 822718879463481778 722296330081651187 953334605269893274 1009903145972283456 94273932496766485 1045164449466553642 719185047838359120 9174...
output:
540805188 209724623 224913308 292637194 539286796 46210618 494591805 43193364 240515170 893233359 54134421 455536894 641024771 868384248 689588299 973292922 5411084 401959756 742933833 325618479 922496999 315641820 499458907 61205446 170295419 265505548 446460060 936773155 206367474 155004066 986553...
result:
ok 169 numbers
Test #11:
score: 0
Accepted
time: 45ms
memory: 6544kb
input:
166 60 438751897612726088 884489715619741346 23331573624464874 930776067265462412 39206478187622273 344702045846930483 336358708039241526 246423880255388410 355338111331239092 501191972975416832 812854079844091372 131788710116818991 485083549946140380 712851737653481480 707183787820265532 5694722665...
output:
505017865 244328792 927344639 677883188 949936571 839752803 641551817 990797216 465518177 62806406 71692954 709749005 652669480 756273241 627226311 507735638 515999266 928603310 104990004 642309248 140191239 609391980 715786045 150545610 174667619 340303901 915009948 150208198 16001630 915760064 904...
result:
ok 166 numbers
Test #12:
score: 0
Accepted
time: 50ms
memory: 7812kb
input:
163 61 606137986164597094 288888906808066084 1075148874264087892 330016912604527219 606346398592488360 948734332384841167 612808446315210925 305201077715513332 560028049479780861 192288153526804840 789160270425808641 1104725498421783449 615630835465346487 373837385237765447 940211620425070518 114300...
output:
975345327 330502973 66545596 625685446 336974815 971935248 628956027 25695672 546021282 641037835 607780784 566453312 572137163 669805025 290615984 64744663 204878686 905048888 974237989 610688344 920096387 517535618 836277689 478344157 148295210 734049074 377010889 853985155 151682954 467017941 711...
result:
ok 163 numbers
Test #13:
score: 0
Accepted
time: 46ms
memory: 9612kb
input:
161 62 204565264782443886 86262081086943157 396383503922503367 441342868074144963 662068935529021160 232386748419747309 311285488989846316 191012590169460885 157941978175301522 451547184819719164 594601365823175856 974151620488863468 772774499757852953 178301110067560089 100998644286448982 100432943...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 161 numbers
Test #14:
score: 0
Accepted
time: 765ms
memory: 44680kb
input:
10 1000 901789285036373850 551281949268396521 878675026029307816 232353893052742618 282478458952634385 594328444125314099 240943963070985986 1351997653528367 67904742576990276 105971007583102831 439932648144504352 930024009301071260 998092707364170936 1001082649286606430 991795711725486065 701333592...
output:
0 0 0 0 0 0 0 0 0 0
result:
ok 10 numbers
Test #15:
score: -100
Time Limit Exceeded
input:
5 2000 430524949516104788 761714890778265787 492578849171032080 885322526997308306 52262836398241401 165051513964825262 1035581243534689912 657180693219234515 231034019148427788 877378881709638819 721070517355819538 812887449257257639 1104545776802998651 133501675578071972 447090182702868582 1658207...