# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
639822 |
2022-09-12T00:00:36 Z |
ggoh |
씽크스몰 (kriii3_TT) |
C++14 |
|
1510 ms |
179540 KB |
#include <bits/stdc++.h>
#define lint long long
using namespace std;
//source : https://github.com/koosaga/DeobureoMinkyuParty/blob/master/teamnote.pdf
//no ntt
typedef complex<double> base;
void fft(vector<base> &a, bool inv)
{
int n = a.size(), j = 0;
vector<base> roots(n / 2);
for (int i = 1; i < n; i++)
{
int bit = (n >> 1);
while (j >= bit)
{
j -= bit;
bit >>= 1;
}
j += bit;
if (i < j)
swap(a[i], a[j]);
}
double ang = 2 * acos(-1) / n * (inv ? -1 : 1);
for (int i = 0; i < n / 2; i++)
{
roots[i] = base(cos(ang * i), sin(ang * i));
}
for (int i = 2; i <= n; i <<= 1)
{
int step = n / i;
for (int j = 0; j < n; j += i)
{
for (int k = 0; k < i / 2; k++)
{
base u = a[j + k], v = a[j + k + i / 2] * roots[step * k];
a[j + k] = u + v;
a[j + k + i / 2] = u - v;
}
}
}
if (inv)
for (int i = 0; i < n; i++)
a[i] /= n;
}
vector<lint> multiply(vector<lint> &v, vector<lint> &w)
{
int n = 2;
while (n < v.size() + w.size())
n <<= 1;
vector<base> v1(n), v2(n), r1(n), r2(n);
for (int i = 0; i < v.size(); i++)
{
v1[i] = base(v[i] >> 15, v[i] & 32767);
}
for (int i = 0; i < w.size(); i++)
{
v2[i] = base(w[i] >> 15, w[i] & 32767);
}
fft(v1, 0);
fft(v2, 0);
for (int i = 0; i < n; i++)
{
int j = (i ? (n - i) : i);
base ans1 = (v1[i] + conj(v1[j])) * base(0.5, 0);
base ans2 = (v1[i] - conj(v1[j])) * base(0, -0.5);
base ans3 = (v2[i] + conj(v2[j])) * base(0.5, 0);
base ans4 = (v2[i] - conj(v2[j])) * base(0, -0.5);
r1[i] = (ans1 * ans3) + (ans1 * ans4) * base(0, 1);
r2[i] = (ans2 * ans3) + (ans2 * ans4) * base(0, 1);
}
fft(r1, 1);
fft(r2, 1);
vector<lint> ret(n);
for (int i = 0; i < n; i++)
{
lint av = (lint)round(r1[i].real());
lint bv = (lint)round(r1[i].imag()) + (lint)round(r2[i].real());
lint cv = (lint)round(r2[i].imag());
ret[i] = (av << 30) + (bv << 15) + cv;
}
return ret;
}
int N, M, x;
vector<lint> f, g;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N>>M;
for (int i = 0; i <= N; i++)
{
cin>>x;
f.push_back(x);
}
for (int i = 0; i <= M; i++)
{
cin>>x;
g.push_back(x);
}
vector<lint> r = multiply(f, g);
lint xo = 0;
for (int i = 0; i < r.size(); i++)
xo ^= r[i];
cout<<xo;
}
Compilation message
tt.cpp: In function 'std::vector<long long int> multiply(std::vector<long long int>&, std::vector<long long int>&)':
tt.cpp:49:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | while (n < v.size() + w.size())
| ~~^~~~~~~~~~~~~~~~~~~~~
tt.cpp:52:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
tt.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for (int i = 0; i < w.size(); i++)
| ~~^~~~~~~~~~
tt.cpp: In function 'int main()':
tt.cpp:104:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
104 | for (int i = 0; i < r.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3020 KB |
Output is correct |
2 |
Correct |
42 ms |
10720 KB |
Output is correct |
3 |
Correct |
38 ms |
11344 KB |
Output is correct |
4 |
Correct |
84 ms |
20692 KB |
Output is correct |
5 |
Correct |
90 ms |
20948 KB |
Output is correct |
6 |
Correct |
76 ms |
20820 KB |
Output is correct |
7 |
Correct |
79 ms |
21084 KB |
Output is correct |
8 |
Correct |
79 ms |
21192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
241 ms |
42832 KB |
Output is correct |
2 |
Correct |
584 ms |
82604 KB |
Output is correct |
3 |
Correct |
609 ms |
84068 KB |
Output is correct |
4 |
Correct |
1472 ms |
172828 KB |
Output is correct |
5 |
Correct |
1432 ms |
169880 KB |
Output is correct |
6 |
Correct |
1473 ms |
175388 KB |
Output is correct |
7 |
Correct |
1444 ms |
179540 KB |
Output is correct |
8 |
Correct |
1510 ms |
177904 KB |
Output is correct |