QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#234408 | #3840. Pass the Ball! | GFFF | Compile Error | / | / | C++14 | 2.2kb | 2023-11-01 16:57:06 | 2023-11-01 16:57:06 |
Judging History
This is the latest submission verdict.
- [2023-11-01 16:57:06]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2023-11-01 16:57:06]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
typedef __float128_t ld;
typedef long long ll;
const int maxn=1e6+5;
const ld pi=acosl(-1.0);
struct cpl{
ld x,y;
cpl friend operator + (const cpl a,const cpl b) {return (cpl){a.x+b.x,a.y+b.y};}
cpl friend operator - (const cpl a,const cpl b) {return (cpl){a.x-b.x,a.y-b.y};}
cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};}
}A[maxn],B[maxn],C[maxn];
struct FNTT{
int mx,tim,r[maxn];
void FFT(cpl *a,int op)
{
for(int i=0;i<mx;++i) if(i<r[i]) swap(a[i],a[r[i]]);
for(int mid=1;mid<mx;mid<<=1)
{
cpl wn=(cpl){cosl(pi/mid),op*sinl(pi/mid)};
for(int i=0,len=mid<<1;i<mx;i+=len)
{
cpl w=(cpl){1,0};
for(int j=0;j<mid;++j,w=w*wn)
{
cpl x=a[i+j],y=w*a[i+mid+j];
a[i+j]=x+y;a[i+mid+j]=x-y;
}
}
}
if(op==1) return ;
for(int i=0;i<mx;++i) a[i].x/=mx;
}
int getlen(int n) {for(mx=1,tim=0;mx<=n;mx<<=1,++tim);return mx;}
void Mul(int n,int *a,int *b,ll *c)
{
for(int i=0;i<mx;++i) r[i]=(r[i>>1]>>1)|((i&1)<<(tim-1));
for(int i=0;i<mx;++i) A[i]=(cpl){1.0*a[i],0},B[i]=(cpl){1.0*b[i],0};
FFT(A,1);FFT(B,1);
for(int i=0;i<mx;++i) C[i]=A[i]*B[i];
FFT(C,-1);
for(int i=0;i<n;++i) c[i]=(ll)(C[i].x+0.5);
}
}fntt;
int n,cnt,q,p[maxn],yet[maxn],a[maxn],b[maxn];
ll ans,c[maxn];
vector<ll> d[maxn];
vector<int> bl[maxn];
vector<int> lenth;
void dfs(int x,int id)
{
yet[x]=1;
bl[id].push_back(x);
if(!yet[p[x]]) dfs(p[x],id);
}
void work(int id)
{
int N=bl[id].size();
int mx=fntt.getlen(N*3);
for(int i=0;i<mx;++i) a[i]=b[i]=c[i]=0;
for(int i=0;i<N;++i) a[i]=b[i]=bl[id][i];
reverse(b,b+N);
for(int i=N;i<N*2;++i) b[i]=b[i-N];
fntt.Mul(N*3,a,b,c);
if(!d[N].size()) d[N].resize(N),lenth.push_back(N);
for(int i=0;i<N;++i) d[N][i]+=c[i+N-1];
}
int main()
{
scanf("%d%d",&n,&q);
for(int i=1;i<=n;++i) scanf("%d",&p[i]);
for(int i=1;i<=n;++i)
if(!yet[i])
{
++cnt;
dfs(i,cnt);
}
for(int i=1;i<=cnt;++i) work(i);
for(int i=1,x;i<=q;++i)
{
scanf("%d",&x);
ans=0;
for(auto len:lenth) ans+=d[len][x%len];
printf("%lld\n",ans);
}
return 0;
}
/*
5 100
2 3 1 5 4
*/
詳細信息
answer.code:3:9: error: ‘__float128_t’ does not name a type; did you mean ‘__float128’? 3 | typedef __float128_t ld; | ^~~~~~~~~~~~ | __float128 answer.code:6:7: error: ‘ld’ does not name a type; did you mean ‘ll’? 6 | const ld pi=acosl(-1.0); | ^~ | ll answer.code:8:9: error: ‘ld’ does not name a type; did you mean ‘ll’? 8 | ld x,y; | ^~ | ll answer.code: In function ‘cpl operator+(cpl, cpl)’: answer.code:9:73: error: ‘const struct cpl’ has no member named ‘x’ 9 | cpl friend operator + (const cpl a,const cpl b) {return (cpl){a.x+b.x,a.y+b.y};} | ^ answer.code:9:77: error: ‘const struct cpl’ has no member named ‘x’ 9 | cpl friend operator + (const cpl a,const cpl b) {return (cpl){a.x+b.x,a.y+b.y};} | ^ answer.code:9:81: error: ‘const struct cpl’ has no member named ‘y’ 9 | cpl friend operator + (const cpl a,const cpl b) {return (cpl){a.x+b.x,a.y+b.y};} | ^ answer.code:9:85: error: ‘const struct cpl’ has no member named ‘y’ 9 | cpl friend operator + (const cpl a,const cpl b) {return (cpl){a.x+b.x,a.y+b.y};} | ^ answer.code: In function ‘cpl operator-(cpl, cpl)’: answer.code:10:73: error: ‘const struct cpl’ has no member named ‘x’ 10 | cpl friend operator - (const cpl a,const cpl b) {return (cpl){a.x-b.x,a.y-b.y};} | ^ answer.code:10:77: error: ‘const struct cpl’ has no member named ‘x’ 10 | cpl friend operator - (const cpl a,const cpl b) {return (cpl){a.x-b.x,a.y-b.y};} | ^ answer.code:10:81: error: ‘const struct cpl’ has no member named ‘y’ 10 | cpl friend operator - (const cpl a,const cpl b) {return (cpl){a.x-b.x,a.y-b.y};} | ^ answer.code:10:85: error: ‘const struct cpl’ has no member named ‘y’ 10 | cpl friend operator - (const cpl a,const cpl b) {return (cpl){a.x-b.x,a.y-b.y};} | ^ answer.code: In function ‘cpl operator*(cpl, cpl)’: answer.code:11:73: error: ‘const struct cpl’ has no member named ‘x’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:77: error: ‘const struct cpl’ has no member named ‘x’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:81: error: ‘const struct cpl’ has no member named ‘y’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:85: error: ‘const struct cpl’ has no member named ‘y’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:89: error: ‘const struct cpl’ has no member named ‘x’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:93: error: ‘const struct cpl’ has no member named ‘y’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:97: error: ‘const struct cpl’ has no member named ‘y’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code:11:101: error: ‘const struct cpl’ has no member named ‘x’ 11 | cpl friend operator * (const cpl a,const cpl b) {return (cpl){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};} | ^ answer.code: In member function ‘void FNTT::FFT(cpl*, int)’: answer.code:20:43: error: ‘pi’ was not declared in this scope 20 | ...