QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544189#6253. Appeal to the Audience xujindongCompile Error//C++14380b2024-09-02 11:45:342024-09-02 11:45:34

Judging History

你现在查看的是最新测评结果

  • [2024-09-02 11:45:34]
  • 评测
  • [2024-09-02 11:45:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using I=int64_t;enum{O=2<<17};I n,k,a[O],b[O],N,S[O],L[O],R,i,f;vector<I>e[O];D(I P){for(I x:e[P])D(x),L[x]>L[S[P]]&&(S[P]=x);for(I x:e[P])if(x!=S[P])b[N++]=L[x];L[P]=L[S[P]]+1;}main(){for(cin>>n>>k;i<k;i++)cin>>a[i];for(i=1;i<n;i++)cin>>f,e[f].push_back(i);for(D(i=0),b[N]=L[0]-1,sort(a,a+k),sort(b,b+k);i<k;i++)R+=a[i]*b[i];cout<<R;}

Details

answer.code:2:99: error: ISO C++ forbids declaration of ‘D’ with no type [-fpermissive]
    2 | using namespace std;using I=int64_t;enum{O=2<<17};I n,k,a[O],b[O],N,S[O],L[O],R,i,f;vector<I>e[O];D(I P){for(I x:e[P])D(x),L[x]>L[S[P]]&&(S[P]=x);for(I x:e[P])if(x!=S[P])b[N++]=L[x];L[P]=L[S[P]]+1;}main(){for(cin>>n>>k;i<k;i++)cin>>a[i];for(i=1;i<n;i++)cin>>f,e[f].push_back(i);for(D(i=0),b[N]=L[0]-1,sort(a,a+k),sort(b,b+k);i<k;i++)R+=a[i]*b[i];cout<<R;}
      |                                                                                                   ^
answer.code: In function ‘int D(I)’:
answer.code:2:198: warning: no return statement in function returning non-void [-Wreturn-type]
    2 | using namespace std;using I=int64_t;enum{O=2<<17};I n,k,a[O],b[O],N,S[O],L[O],R,i,f;vector<I>e[O];D(I P){for(I x:e[P])D(x),L[x]>L[S[P]]&&(S[P]=x);for(I x:e[P])if(x!=S[P])b[N++]=L[x];L[P]=L[S[P]]+1;}main(){for(cin>>n>>k;i<k;i++)cin>>a[i];for(i=1;i<n;i++)cin>>f,e[f].push_back(i);for(D(i=0),b[N]=L[0]-1,sort(a,a+k),sort(b,b+k);i<k;i++)R+=a[i]*b[i];cout<<R;}
      |                                                                                                                                                                                                      ^
answer.code: At global scope:
answer.code:2:199: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    2 | using namespace std;using I=int64_t;enum{O=2<<17};I n,k,a[O],b[O],N,S[O],L[O],R,i,f;vector<I>e[O];D(I P){for(I x:e[P])D(x),L[x]>L[S[P]]&&(S[P]=x);for(I x:e[P])if(x!=S[P])b[N++]=L[x];L[P]=L[S[P]]+1;}main(){for(cin>>n>>k;i<k;i++)cin>>a[i];for(i=1;i<n;i++)cin>>f,e[f].push_back(i);for(D(i=0),b[N]=L[0]-1,sort(a,a+k),sort(b,b+k);i<k;i++)R+=a[i]*b[i];cout<<R;}
      |                                                                                                                                                                                                       ^~~~