QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#199346#6347. XOR Determinantucup-team870#WA 17ms3572kbC++141.2kb2023-10-04 09:40:192023-10-04 09:40:20

Judging History

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

  • [2023-10-04 09:40:20]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3572kb
  • [2023-10-04 09:40:19]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define per(i,r,l) for(int i=r; i>=l; i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const int mod=998244353,N=62;
ll v[N][N];
ll qp(ll x,ll y){
    ll res=1; x=(x%mod+mod)%mod;
    while(y){
        if(y&1)res=res*x%mod;
        x=x*x%mod; y>>=1;
    } return res;
}
void slv(){
    int n; cin>>n;
    vector<ll>a(n+1),b(n+1);
    rep(i,1,n)cin>>a[i];
    rep(i,1,n)cin>>b[i];
    if(n>60){
        cout<<"0\n"; return;
    }
    rep(i,1,n){
        rep(j,1,n)v[i][j]=(a[i]^b[j])%mod;
    }
    int ans=1;
    rep(i,1,n){
        rep(j,i,n){
            if(v[j][i]){
                if(j!=i)ans=-ans;
                swap(v[i],v[j]); break;
            }
        }
        if(!v[i][i]){
            cout<<"0\n";return;
        }
        ll inv=qp(v[i][i],mod-2);
        rep(j,i+1,n){
            ll t=inv*v[j][i]%mod;
            rep(k,i,n)v[j][k]=(v[j][k]-t*v[i][k])%mod;
        }
        ans=ans*v[i][i]%mod;
    }
    cout<<(ans%mod+mod)%mod<<'\n';
}
int main() {
    IOS
    int T;cin>>T;
    while(T--)slv();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3476kb

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: 1ms
memory: 3468kb

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: 1ms
memory: 3428kb

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: 15ms
memory: 3500kb

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: 17ms
memory: 3572kb

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: 13ms
memory: 3476kb

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: -100
Wrong Answer
time: 2ms
memory: 3544kb

input:

163
61
80980377743349794 78082725295428680 808378069808536832 277850281918593630 877981892336811364 898303075033883084 323880166130506137 525399171051596912 366242148391474277 120856593948882151 723420323440470677 764275661616196241 647981809066855810 259339928715802532 1105675893907201571 986085105...

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:

wrong answer 1st numbers differ - expected: '781999390', found: '0'