QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#87328 | #5748. Determinant, or...? | dalfasewf | WA | 2ms | 3524kb | C++14 | 891b | 2023-03-12 16:04:01 | 2023-03-12 16:04:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k;
const ll mod=1e9+9;
ll a[4000009];
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
ll i,j,t,x,y,z,last,now;
cin>>n;
ll ans=1;
x=(1ll<<n)-1;
for(i=0;i<(1ll<<n);i++)cin>>a[i];
if(n==1){
ans=((a[0]*a[1]-a[1]*a[1])%mod+mod)%mod;
cout<<ans;
return 0;
}
y=x;
for(i=x;i>=0;i-=4){
for(j=0;j<4;j++){
k=i-j;
if(j==0){
if(i==x)ans=(ans*a[i])%mod;
else ans=(ans*(a[x]-a[k])%mod+mod)%mod;
}
else if(j<3){
if(i==x)ans=(ans*(a[x]-a[k])%mod+mod)%mod;
else ans=(ans*(a[x]-a[x-j]-a[y]+a[k])%mod+mod)%mod;
}
else {
if(i==x)ans=(ans*(a[x]+a[k]-a[x-1]-a[x-2])%mod+mod)%mod;
else ans=(ans*(a[x]+a[x-3]-a[x-1]-a[x-2]-a[y]-a[k]+a[y-1]+a[y-2])%mod+mod)%mod;
}
}
y-=4;
}
cout<<ans<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3368kb
input:
1 5 2
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3340kb
input:
2 3 1 5 4
output:
999999997
result:
ok 1 number(s): "999999997"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
3 53 37 42 42 84 37 66 8
output:
47229676
result:
ok 1 number(s): "47229676"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
3 762493332 721658786 22070969 135208254 466384641 652280022 979534282 601978718
output:
281502235
result:
ok 1 number(s): "281502235"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3340kb
input:
3 129388930 489520730 263815343 315708585 263026886 153021985 251231378 649675390
output:
346896861
result:
ok 1 number(s): "346896861"
Test #6:
score: -100
Wrong Answer
time: 2ms
memory: 3456kb
input:
4 354170434 589724459 964138381 855919536 741407874 653645432 210017100 9041114 623557907 889004048 499789082 377902011 20698775 389133769 126649035 441324014
output:
564317063
result:
wrong answer 1st numbers differ - expected: '474257110', found: '564317063'