# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
526082 |
2022-02-13T16:45:10 Z |
eric00513 |
씽크스몰 (kriii3_TT) |
C++17 |
|
3238 ms |
229364 KB |
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (ll)(x).size()
#define all(x) (x).begin(), (x).end()
using ll = unsigned long long;
using base = complex<long double>;
const long double PI = acos(-1.L);
void fft(vector<base>& a, bool inv) {
ll n = sz(a);
for (ll i = 1, j = 0; i < n; i++) {
ll bit = n >> 1;
while (j >= bit) j -= bit, bit >>= 1;
j += bit;
if (i < j) swap(a[i], a[j]);
}
for (ll len = 2; len <= n; len <<= 1) {
vector<base> w(len / 2);
for (ll i = 0; i < len / 2; i++) {
long double ang = 2 * PI * i / len * (inv ? -1 : 1);
w[i] = base(cos(ang), sin(ang));
}
for (ll i = 0; i < n; i += len) {
for (ll j = 0; j < len / 2; j++) {
base u = a[i + j], v = a[i + j + len / 2] * w[j];
a[i + j] = u + v;
a[i + j + len / 2] = u - v;
}
}
}
if (inv) for (ll i = 0; i < n; i++) a[i] /= n;
}
vector<ll> multiply(vector<ll>& a, vector<ll>& b) {
vector<base> fa(all(a)), fb(all(b));
ll n = sz(fa);
fft(fa, false); fft(fb, false);
for (ll i = 0; i < n; i++) fa[i] *= fb[i];
fft(fa, true);
vector<ll> ret(n);
for (ll i = 0; i < n; i++) ret[i] = (ll)(fa[i].real() + (fa[i].real() > 0 ? 0.5 : -0.5));
return ret;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
ll n, m;
cin >> n >> m;
n++, m++;
ll k = 1;
while (k < 2 * max(n, m) - 1) k <<= 1;
vector<ll> a(k), b(k);
for (ll i = 0; i < n; i++) cin >> a[i];
for (ll i = 0; i < m; i++) cin >> b[i];
vector<ll> res = multiply(a, b);
ll ans = 0;
for (ll i = 0; i < n + m - 1; i++) ans ^= res[i];
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Correct |
3 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
3 ms |
460 KB |
Output is correct |
8 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
3488 KB |
Output is correct |
2 |
Correct |
380 ms |
25004 KB |
Output is correct |
3 |
Correct |
354 ms |
24988 KB |
Output is correct |
4 |
Correct |
357 ms |
24996 KB |
Output is correct |
5 |
Correct |
357 ms |
25008 KB |
Output is correct |
6 |
Correct |
371 ms |
24912 KB |
Output is correct |
7 |
Correct |
367 ms |
25024 KB |
Output is correct |
8 |
Correct |
362 ms |
24928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
764 ms |
49636 KB |
Output is correct |
2 |
Correct |
1560 ms |
102692 KB |
Output is correct |
3 |
Correct |
1530 ms |
103316 KB |
Output is correct |
4 |
Correct |
3206 ms |
225088 KB |
Output is correct |
5 |
Correct |
3238 ms |
223840 KB |
Output is correct |
6 |
Correct |
3205 ms |
226252 KB |
Output is correct |
7 |
Correct |
3203 ms |
229364 KB |
Output is correct |
8 |
Correct |
3210 ms |
227828 KB |
Output is correct |