# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
51797 |
2018-06-21T08:13:32 Z |
jh05013 |
씽크스몰 (kriii3_TT) |
C++17 |
|
1595 ms |
66316 KB |
#include <bits/stdc++.h>
#define dbgv(v) {for(auto x:v)cout<<x<<' ';cout<<'\n';}
#define entire(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
void OJize(){
cin.tie(NULL); ios_base::sync_with_stdio(false);
#ifdef jh
freopen("input.txt", "r", stdin);
#endif
}
int SZ = 1, N = 1<<SZ;
int Rev(int x){
int r = 0;
for(int i=0; i<SZ; i++) r = r<<1 | (x&1), x>>= 1;
return r;
}
const long double PI = acos(-1);
typedef complex<long double> CD;
typedef vector<CD> VCD;
void FFT(VCD& A, int f){
CD x, y, z;
for(int i=0; i<N; i++){
int j = Rev(i);
if(i < j) swap(A[i], A[j]);
}
for(int i=1; i<N; i<<= 1){
double w = PI / i;
if(f) w = -w;
CD x(cos(w), sin(w));
for(int j=0; j<N; j+= i<<1){
CD y(1);
for(int k=0; k<i; k++){
CD z = A[i+j+k] * y;
A[i+j+k] = A[j+k] - z, A[j+k]+= z;
y*= x;
}
}
}
if(f) for(int i=0; i<N; i++) A[i]/= N;
}
int main(){OJize();
int n, m, x; cin>>n>>m;
while(n+m+2 > N) SZ++, N<<=1;
VCD A(N), B(N), AR(N), BR(N);
for(int i=0; i<n+1; i++) cin>>x, A[i] = CD(x>>16, x&65535);
for(int i=0; i<m+1; i++) cin>>x, B[i] = CD(x>>16, x&65535);
FFT(A, 0); FFT(B, 0);
for(int i=0; i<N; i++){
int j = i? N-i : i;
CD f1 = (A[i] + conj(A[j])) / CD(2, 0), f2 = (A[i] - conj(A[j])) / CD(0, 2),
f3 = (B[i] + conj(B[j])) / CD(2, 0), f4 = (B[i] - conj(B[j])) / CD(0, 2);
AR[i] = f1 * (f3 + f4 * CD(0, 1)), BR[i] = f2 * (f3 + f4 * CD(0, 1));
}
FFT(AR, 1); FFT(BR, 1);
ll ans = 0;
for(int i=0; i<n+m+2; i++){
ll ar = roundl(real(AR[i])) + 0.01, ai = roundl(imag(AR[i])) + 0.01,
br = roundl(real(BR[i])) + 0.01, bi = roundl(imag(BR[i])) + 0.01;
ll res = bi + ((ai + br) << 16) + (ar << 32);
ans^= res;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
3 ms |
484 KB |
Output is correct |
4 |
Correct |
4 ms |
644 KB |
Output is correct |
5 |
Correct |
6 ms |
732 KB |
Output is correct |
6 |
Correct |
6 ms |
896 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
6 ms |
908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
4632 KB |
Output is correct |
2 |
Correct |
334 ms |
16924 KB |
Output is correct |
3 |
Correct |
331 ms |
16976 KB |
Output is correct |
4 |
Correct |
713 ms |
33360 KB |
Output is correct |
5 |
Correct |
725 ms |
33488 KB |
Output is correct |
6 |
Correct |
738 ms |
33508 KB |
Output is correct |
7 |
Correct |
800 ms |
33508 KB |
Output is correct |
8 |
Correct |
776 ms |
33508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1595 ms |
66316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |