QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#719845#9562. 欧伊昔wsc20080 7ms46740kbC++142.0kb2024-11-07 09:21:012024-11-07 09:21:02

Judging History

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

  • [2024-11-07 09:21:02]
  • 评测
  • 测评结果:0
  • 用时:7ms
  • 内存:46740kb
  • [2024-11-07 09:21:01]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void write(ll x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
const ll N=1.8e5+9;
ll n,pw3[12],op[3][3],a[N],b[N],c[N],D;
ll f[12][N],g[12][N],h[12][N];
ll p[5][3],q[5][3],r[5][3];
void Karatsuba(ll d){
    if(d==1){
        rep(i,0,2)h[d][i]=0;
        rep(i,0,2){
            rep(j,0,2)h[d][op[i][j]]+=f[d][i]*g[d][j];
        }
        return ;
    }
    ll L=pw3[d-1];
    rep(i,0,L*3-1)h[d][i]=0;
    rep(t,0,D-1){
        rep(i,0,L-1){
            f[d-1][i]=f[d][i]*p[t][0]+f[d][i+L]*p[t][1]+f[d][i+L+L]*p[t][2];
            g[d-1][i]=g[d][i]*q[t][0]+g[d][i+L]*q[t][1]+g[d][i+L+L]*q[t][2];
        }
        Karatsuba(d-1);
        rep(i,0,L-1){
            h[d][i]+=h[d-1][i]*r[t][0];
            h[d][i+L]+=h[d-1][i]*r[t][1];
            h[d][i+L+L]+=h[d-1][i]*r[t][2];
        }
    }
}
bool Med;
int main(){
    cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
    rep(i,0,2){
        rep(j,0,2)op[i][j]=read();
    }
    n=read();
    pw3[0]=1;
    rep(i,1,n)pw3[i]=pw3[i-1]*3;
    rep(i,0,pw3[n]-1)a[i]=read();
    rep(i,0,pw3[n]-1)b[i]=read();
    rep(i,0,pw3[n]-1)f[n][i]=a[i],g[n][i]=b[i];
    D=4;
    rep(i,0,2)p[0][i]=q[0][i]=1;
    rep(i,0,2){
        rep(j,0,2){
            if(op[i][j]==1)p[i+1][j]=1;
            q[i+1][i]=1;
        }
    }
    r[1][1]=r[2][1]=r[3][1]=1;
    r[0][0]=1,r[1][0]=r[2][0]=r[3][0]=-1;
    Karatsuba(n);
    rep(i,0,pw3[n]-1)c[i]=h[n][i];
    rep(i,0,pw3[n]-1)write(c[i]),putchar(' ');
    putchar('\n');
    cerr<<"\n"<<clock()*1.0/CLOCKS_PER_SEC*1000<<"ms\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 3ms
memory: 14176kb

input:

0 1 2
1 2 0
2 0 1
1
7 1 5
8 4 5

output:

81 61 79 

result:

ok single line: '81 61 79 '

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 24372kb

input:

0 1 2
1 2 0
2 0 1
3
6 4 1 8 7 9 6 1 4 1 6 4 5 8 2 5 2 8 1 8 7 9 8 1 1 8 8
9 6 5 9 8 7 5 0 4 7 7 1 1 8 0 9 2 2 8 9 3 8 8 5 2 1 5

output:

2795 2827 2842 1344 1485 1515 0 0 0 1441 1419 1381 676 751 706 0 0 0 0 0 0 0 0 0 0 0 0 

result:

wrong answer 1st lines differ - expected: '697 607 678 641 734 754 699 75...706 636 703 751 761 713 764 754', found: '2795 2827 2842 1344 1485 1515 ...51 706 0 0 0 0 0 0 0 0 0 0 0 0 '

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 5
Accepted
time: 0ms
memory: 14172kb

input:

1 2 1
2 0 0
1 0 0
1
8 9 3
1 6 1

output:

84 19 57 

result:

ok single line: '84 19 57 '

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 24416kb

input:

1 2 1
2 0 0
1 0 0
3
0 9 8 8 9 2 6 5 1 7 2 9 8 8 7 9 1 9 8 0 3 6 8 6 6 1 6
2 7 1 0 3 4 9 1 7 3 1 3 3 6 1 4 6 7 3 9 5 0 6 5 6 6 8

output:

3919 2654 1922 1505 1449 751 0 0 0 1676 1099 818 984 446 409 0 0 0 0 0 0 0 0 0 0 0 0 

result:

wrong answer 1st lines differ - expected: '2070 1350 930 936 1077 524 774...715 415 569 372 227 360 144 155', found: '3919 2654 1922 1505 1449 751 0...46 409 0 0 0 0 0 0 0 0 0 0 0 0 '

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 20
Accepted
time: 0ms
memory: 14132kb

input:

1 1 1
0 0 0
1 1 1
1
6 2 1
3 1 5

output:

18 63 0 

result:

ok single line: '18 63 0 '

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 22388kb

input:

1 1 0
0 0 1
0 0 1
3
4 6 4 5 6 8 7 7 4 0 0 9 1 0 9 0 8 5 3 4 0 0 4 2 3 5 1
4 2 5 5 6 2 4 6 5 2 5 0 0 4 0 6 3 8 1 2 3 7 0 6 8 4 8

output:

2107 1567 0 1594 1151 0 0 0 0 1586 1030 0 1222 873 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

wrong answer 1st lines differ - expected: '1776 1049 0 1615 1167 0 0 0 0 ... 1202 0 0 0 0 0 0 0 0 0 0 0 0 0', found: '2107 1567 0 1594 1151 0 0 0 0 ... 873 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 30
Accepted
time: 0ms
memory: 12132kb

input:

1 1 1
0 0 1
1 1 0
1
1 0 9
8 1 9

output:

81 99 0 

result:

ok single line: '81 99 0 '

Test #17:

score: 30
Accepted
time: 4ms
memory: 20216kb

input:

0 0 1
0 0 1
1 1 0
3
7 6 2 7 7 9 5 5 6 0 5 7 5 8 1 0 6 0 9 3 3 5 1 8 2 2 1
8 5 9 1 0 0 0 4 9 1 4 3 2 5 1 9 2 2 8 7 6 8 7 3 9 1 0

output:

2402 1847 0 1687 1320 0 0 0 0 2363 1614 0 1492 955 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok single line: '2402 1847 0 1687 1320 0 0 0 0 ... 955 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Test #18:

score: 0
Wrong Answer
time: 0ms
memory: 36696kb

input:

1 0 0
0 1 0
1 0 1
6
4 6 4 1 9 6 7 6 7 5 0 7 4 1 5 7 5 7 4 7 9 7 6 3 3 8 5 4 4 0 8 8 9 2 8 3 5 9 3 1 4 1 1 5 7 7 7 5 7 4 9 8 1 0 7 9 3 8 4 8 2 9 5 3 4 0 5 3 8 2 7 8 8 7 4 8 5 2 4 2 1 0 6 1 7 0 1 2 9 8 3 5 9 9 0 1 6 3 9 7 0 1 9 8 4 4 4 3 1 4 5 4 4 6 2 2 7 2 6 5 8 5 4 5 9 7 4 1 7 1 3 2 6 3 6 0 0 5 9 6 ...

output:

310969 248511 0 245773 196350 0 0 0 0 251348 199963 0 204708 164763 0 0 0 0 0 0 0 0 0 0 0 0 0 255663 202567 0 200677 160308 0 0 0 0 210990 166540 0 166755 134612 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255230 200843 0 200276 160221 0 0 0 0 207257 162518 0 1666...

result:

wrong answer 1st lines differ - expected: '322011 265965 0 260223 215956 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0', found: '310969 248511 0 245773 196350 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Subtask #5:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 7ms
memory: 46740kb

input:

0 2 2
1 1 1
0 1 1
9
2 7 2 7 4 5 9 7 9 6 8 4 0 6 3 3 6 3 0 5 2 3 7 6 7 8 3 6 1 1 6 9 9 2 7 2 1 2 8 2 9 3 5 0 5 7 1 2 3 1 4 8 0 4 3 4 2 8 8 4 2 9 3 7 1 1 6 6 4 0 9 6 5 8 8 1 3 8 7 3 0 4 3 8 7 0 0 7 6 4 3 6 0 2 3 3 6 5 0 5 9 8 6 1 0 4 7 8 2 4 7 4 8 6 9 6 3 5 1 8 0 1 4 7 0 0 1 2 7 7 0 5 5 3 8 2 7 8 9 8 ...

output:

2533410 6929954 2845189 3320588 8246074 3330738 0 0 0 3290644 7661154 3037438 4742216 10828410 4296086 0 0 0 0 0 0 0 0 0 0 0 0 3182554 8032954 3257035 4033916 10646155 4354236 0 0 0 4328827 10097677 4041415 5498249 13051001 5249370 0 0 0 0 0 0 0 0 0 0 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 lines differ - expected: '18440 36200 13740 21447 61214 ...176 81555 44223 4512 28578 4596', found: '2533410 6929954 2845189 332058... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%