QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#719781 | #9562. 欧伊昔 | wsc2008 | 5 | 59ms | 57976kb | C++14 | 2.1kb | 2024-11-07 08:51:56 | 2024-11-07 08:51:56 |
Judging History
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;
p[0][1]=p[0][2]=q[0][1]=q[0][2]=1;//d0=(a1+a2)(b1+b2)
p[1][0]=p[1][2]=q[1][0]=q[1][2]=1;//d1=(a0+a2)(b0+b2)
p[2][2]=q[2][2]=1;//d2=a2*b2
p[3][0]=p[3][1]=p[3][2]=q[3][0]=q[3][1]=q[3][2]=1;//d3=(a0+a1+a2)*(b0+b1+b2)
r[0][0]=1;//c0=d0
r[1][1]=1,r[2][1]=-1;//c1=d1-d2
r[0][2]=-1,r[1][2]=-1,r[2][2]=1,r[3][2]=1;//c2=-d0-d1+d2+d3
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: 2ms
memory: 14164kb
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: 22360kb
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:
1073 1128 1114 801 833 998 586 689 690 1113 1106 1106 623 647 601 741 747 711 616 576 568 383 388 321 320 368 335
result:
wrong answer 1st lines differ - expected: '697 607 678 641 734 754 699 75...706 636 703 751 761 713 764 754', found: '1073 1128 1114 801 833 998 586...76 568 383 388 321 320 368 335 '
Subtask #2:
score: 5
Accepted
Test #6:
score: 5
Accepted
time: 1ms
memory: 12076kb
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: 5
Accepted
time: 2ms
memory: 22380kb
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:
2070 1350 930 936 1077 524 774 445 422 995 939 563 984 446 409 681 160 255 715 715 415 569 372 227 360 144 155
result:
ok single line: '2070 1350 930 936 1077 524 774...15 415 569 372 227 360 144 155 '
Test #8:
score: 5
Accepted
time: 0ms
memory: 34644kb
input:
1 2 1 2 0 0 1 0 0 6 4 6 7 3 1 5 3 4 8 5 8 4 8 2 5 9 5 8 9 9 5 0 1 3 3 6 2 6 2 0 7 4 1 9 3 0 1 4 7 6 3 5 6 6 6 8 5 4 7 6 5 6 0 9 3 3 7 7 5 3 2 8 8 6 6 7 5 1 5 0 4 0 6 4 4 0 8 8 9 7 2 3 9 1 2 7 7 5 9 4 2 0 4 0 7 3 2 0 0 5 7 3 0 3 1 4 7 1 5 0 5 7 0 7 3 3 3 0 4 4 8 3 0 3 5 4 6 4 6 2 5 2 6 0 1 0 3 2 7 2 ...
output:
83790 80087 47498 54766 53378 30734 37004 38711 20149 56840 51419 30908 44535 34931 19224 28930 21902 13476 40400 35311 23275 29138 24090 14354 18657 16767 10404 54800 54365 26409 41788 36518 23297 26116 26545 15046 43022 40283 20072 32970 27617 15595 19273 21888 11540 29066 27596 14097 20358 17763 ...
result:
ok single line: '83790 80087 47498 54766 53378 ... 3398 2919 2036 2020 2095 1314 '
Test #9:
score: 5
Accepted
time: 3ms
memory: 49084kb
input:
1 2 1 2 0 0 1 0 0 9 1 4 5 7 9 9 3 2 8 2 1 9 6 3 7 1 5 1 8 5 5 2 2 6 4 0 2 2 4 5 5 6 1 0 4 3 4 6 8 5 9 6 5 0 6 3 9 9 6 0 3 0 9 8 4 8 5 2 6 2 3 7 6 1 6 0 0 0 6 9 1 5 1 1 6 9 3 0 1 6 3 9 9 4 1 6 7 6 1 9 4 8 3 7 5 6 7 7 4 2 1 8 0 2 0 1 4 9 6 1 3 9 3 9 1 7 6 3 5 1 2 9 5 9 1 9 0 2 6 8 0 3 2 3 3 8 7 5 7 5 ...
output:
5491236 3870726 2722667 4095376 3095055 2071305 2714963 2074656 1399744 4044155 3120903 2064947 3040305 2366779 1542749 2083106 1574507 1033341 2685025 2000208 1380383 2078336 1610975 1031792 1345673 1054928 715576 4117744 2722921 1889883 3038009 1917155 1380031 2125417 1319541 942766 2939040 204967...
result:
ok single line: '5491236 3870726 2722667 409537...8 22661 14107 20702 15112 9567 '
Test #10:
score: 5
Accepted
time: 59ms
memory: 57976kb
input:
1 2 1 2 0 0 1 0 0 11 7 0 4 5 4 2 8 0 5 2 6 3 3 3 7 4 9 1 2 5 3 2 2 4 9 2 3 4 2 6 6 4 7 8 5 4 0 2 1 1 2 2 6 3 6 5 6 8 3 9 3 4 5 0 6 7 1 9 3 7 9 2 6 8 8 2 4 6 4 1 8 9 2 7 7 8 4 3 8 8 9 3 8 8 8 0 2 0 1 8 8 4 5 6 8 8 8 3 4 0 2 7 6 5 0 8 8 0 5 1 9 7 2 4 4 9 5 8 8 7 3 7 3 4 0 1 8 6 5 5 9 0 0 6 3 7 1 3 5 3...
output:
86479708 63720192 41859212 65499632 45056892 30743097 43125563 31086911 20505561 62406595 47201203 31455187 48665387 34840892 23780593 31386819 23538226 15647083 41894617 31577694 20829302 32537059 22546949 15608457 21012850 15484091 10337868 62979540 46676543 31353425 48890707 34173423 23561609 319...
result:
ok single line: '86479708 63720192 41859212 654... 93847 60903 84153 63837 41857 '
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 20
Accepted
time: 2ms
memory: 14212kb
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: 24356kb
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:
1176 876 0 659 427 0 314 166 0 1525 1152 0 694 621 0 464 380 0 890 531 0 491 348 0 296 120 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: '1176 876 0 659 427 0 314 166 0... 890 531 0 491 348 0 296 120 0 '
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 30
Accepted
time: 2ms
memory: 12084kb
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: 0
Wrong Answer
time: 0ms
memory: 24416kb
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:
1307 604 0 1016 707 0 875 639 0 1031 873 0 1283 1030 0 903 694 0 581 518 0 575 420 0 373 251 0
result:
wrong answer 1st lines differ - expected: '2402 1847 0 1687 1320 0 0 0 0 ...2 955 0 0 0 0 0 0 0 0 0 0 0 0 0', found: '1307 604 0 1016 707 0 875 639 ... 581 518 0 575 420 0 373 251 0 '
Subtask #5:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 4ms
memory: 51052kb
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:
2503032 6402858 2530098 1855504 4605236 1887843 1237088 3180721 1299159 1876972 4767539 1857250 1522146 3559658 1524668 994442 2359143 1041094 1326732 3227208 1139182 979994 2420963 948490 682910 1640488 647371 2027257 4893928 1945132 1429294 3378448 1383293 1045630 2460274 999762 1550944 3620075 16...
result:
wrong answer 1st lines differ - expected: '18440 36200 13740 21447 61214 ...176 81555 44223 4512 28578 4596', found: '2503032 6402858 2530098 185550...90 38684 15386 9819 24652 9283 '
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%