Submission #140189

#TimeUsernameProblemLanguageResultExecution timeMemory
140189ggohGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include "gondola.h" #include <bits/stdc++.h> int ch[100005],i; struct A{ int val,ind; }data[100005]; bool cmp(A aa,A bb){return aa.val<bb.val;} long long X=1e9+9; long long pow(long long p,long long q) { if(q==0)return 1ll; if(q==1)return p; long long O=pow(p,q/2); if(q%2)return O*O%X*p%X; return O*O%X; } int valid(int n, int inputSeq[]) { int ST=-1,st,C=1; for(i=0;i<n;i++)ch[i]=0; for(i=0;i<n;i++) { if(ch[inputSeq[i]]==1){C=0;break;} ch[inputSeq[i]]=1; } for(i=0;i<n;i++) { if(inputSeq[i]<=n) { st=i-inputSeq[i]+1;st=(st+n)%n; if(ST==-1)ST=st; else if(ST!=st){C=0;break;} } } return C; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int ST=0,ba,sz=0,ans=0; for(i=0;i<n;i++) { if(gondolaSeq[i]<=n)ST=(i-gondolaSeq[i]+1+n)%n; else data[sz++]={gondolaSeq[i],i}; } std::sort(data,data+sz,cmp); ba=n; for(i=0;i<sz;i++) { replacementSeq[ans++]=(data[i].ind-ST+n)%n+1; for(int j=ba+1;j<data[i].val;j++) { replacementSeq[ans++]=j; } ba=data[i].val; } return ans; } //---------------------- int countReplacement(int n, int inputSeq[]) { if(valid(n,inputSeq)==0)return 0; int m=0,ST=-1,ba,sz=0; long long ans=1ll; for(i=0;i<n;i++) { if(inputSeq[i]<=n)ST=(i-inputSeq[i]+1+n)%n; else data[sz++]={inputSeq[i],i}; } if(ST==-1)ST=0,ans*=n; std::sort(data,data+sz,cmp); ba=n; for(i=0;i<sz;i++) { ans*=pow(sz-i,data[i].val-ba-1); ans%=X; ba=data[i].val; } return ans; }

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:81:39: error: call of overloaded 'pow(int, int)' is ambiguous
         ans*=pow(sz-i,data[i].val-ba-1);
                                       ^
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from gondola.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:153:1: note: candidate: double pow(double, double)
 __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
 ^
gondola.cpp:11:11: note: candidate: long long int pow(long long int, long long int)
 long long pow(long long p,long long q)
           ^~~
gondola.cpp:69:9: warning: unused variable 'm' [-Wunused-variable]
     int m=0,ST=-1,ba,sz=0;
         ^