QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#646398 | #3840. Pass the Ball! | lllei | Compile Error | / | / | C++20 | 3.4kb | 2024-10-16 22:45:58 | 2024-10-16 22:45:59 |
Judging History
This is the latest submission verdict.
- [2024-10-16 22:45:59]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-16 22:45:58]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
const int BS = 400;
const double Pi = acos(-1.0);
struct Complex
{
double x, y;
Complex(int X = 0, int Y = 0) { x = X, y = Y; }
Complex(double X = 0, double Y = 0) { x = X, y = Y; }
Complex operator+(const Complex b) const { return Complex(x + b.x, y + b.y); }
Complex operator-(const Complex b) const { return Complex(x - b.x, y - b.y); }
Complex operator*(const Complex b) const { return Complex(x * b.x - y * b.y, y * b.x + x * b.y); }
double get() { return x; }
};
int limit = 0, L = 0, rev[1000005];
void initfft(int len)
{
limit = 1, L = 0;
while (limit <= len)
limit <<= 1, L++;
for (int i = 0; i < limit; i++)
rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (L - 1));
}
void FFT(Complex *A, int type)
{
for (int i = 0; i < limit; i++)
if (rev[i] < i)
swap(A[i], A[rev[i]]);
for (int mid = 1; mid < limit; mid <<= 1)
{
Complex w = Complex(cos(Pi / mid), type * sin(Pi / mid));
for (int j = 0; j < limit; j += mid << 1)
{
Complex wn = Complex(1, 0);
for (int k = 0; k < mid; k++, wn = wn * w)
{
Complex x = A[j + k], y = wn * A[j + k + mid];
A[j + k] = x + y, A[j + k + mid] = x - y;
}
}
}
}
Int A[1000005], B[1000005];
int n, q;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q;
vector<int> to(n + 1);
vector<int> vis(n + 1, 0);
vector<vector<long long>> b;
vector<vector<long long>> c(BS, vector<long long>(BS));
for (int i = 1; i <= n; i++)
cin >> to[i];
for (int i = 1; i <= n; i++)
if (!vis[i])
{
vector<int> tmp;
for (int j = i; !vis[j]; j = to[j])
{
vis[j] = 1;
tmp.push_back(j);
}
if (tmp.size() < BS)
{
int siz = tmp.size();
for (int j = 0; j < siz; j++)
for (int k = 0; k < siz; k++)
{
int t = (k < j ? k + siz - j : k - j);
c[siz][t] += tmp[j] * 1ll * tmp[k];
}
}
else
{
vector<long long> ss;
int siz = tmp.size();
initfft(siz * 2);
for (int j = 0; j < limit; j++)
A[j] = B[j] = Complex(0, 0);
for (int j = 0; j < siz; j++)
A[j] = Complex(tmp[j], 0);
for (int j = siz; j < 2 * siz; j++)
A[j] = Complex(tmp[j-siz], 0);
for (int j = 0; j < siz; j++)
B[j] = Complex(tmp[siz - 1 - j],0);
FFT(A, 1);
FFT(B, 1);
for (int j = 0; j < limit; j++)
A[j] = A[j] * B[j];
FFT(A, -1);
for (int j = siz - 1; j < 2 * siz - 1; j++)
ss.push_back(A[j].get());
b.push_back(ss);
}
}
while (q--)
{
long long ans = 0;
int k;
cin >> k;
for (int i = 1; i < BS; i++)
ans += c[i][k % i];
for (const auto &i:b)
ans += i[k % i.size()];
cout<<ans<<'\n';
}
}
Details
answer.code:43:1: error: ‘Int’ does not name a type; did you mean ‘int’? 43 | Int A[1000005], B[1000005]; | ^~~ | int answer.code: In function ‘int main()’: answer.code:81:21: error: ‘A’ was not declared in this scope 81 | A[j] = B[j] = Complex(0, 0); | ^ answer.code:81:28: error: ‘B’ was not declared in this scope 81 | A[j] = B[j] = Complex(0, 0); | ^ answer.code:83:21: error: ‘A’ was not declared in this scope 83 | A[j] = Complex(tmp[j], 0); | ^ answer.code:85:21: error: ‘A’ was not declared in this scope 85 | A[j] = Complex(tmp[j-siz], 0); | ^ answer.code:87:21: error: ‘B’ was not declared in this scope 87 | B[j] = Complex(tmp[siz - 1 - j],0); | ^ answer.code:88:21: error: ‘A’ was not declared in this scope 88 | FFT(A, 1); | ^ answer.code:89:21: error: ‘B’ was not declared in this scope 89 | FFT(B, 1); | ^