Submission #308115

#TimeUsernameProblemLanguageResultExecution timeMemory
308115juggernautGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include"gondola.h" #include<bits/stdc++.h> //#include"grader.cpp" using namespace std; ll mod=1e9+7; int valid(int n,int a[]){ int i=0,need; while(i<n&&a[i]>n)i++; need=a[i]; while(i<n){ if(a[i]<=n&&a[i]!=need)return 0; if(need==n)need=1; else need++; i++; } sort(a,a+n); for(i=1;i<n;i++)if(a[i]==a[i-1])return 0; return 1; } int replacement(int n,int a[],int res[]){ vector<pair<int,int>>b; int i=0,ind=n,need=1,len=0,x; while(i<n&&a[i]>n)i++; if(i!=n)need=a[i]-i; if(need<1)need+=n; for(i=0;i<n;i++,need=need%n+1)b.push_back({a[i],need}); sort(b.begin(),b.end()); i=0; while(i<n){ if(b[i].first<=n){ i++; continue; } res[len++]=b[i].second; x=++ind; while(x!=b[i].first){ res[len++]=x; x=++ind; } i++; } return len; } ll pw(ll a,ll b){ if(!b)return 1; if(b&1)return (1ll*a*pw(a,b-1))%mod; ll x=pw(a,b>>1ll); return (1ll*x*x)%mod; } int countReplacement(int n,int a[]){ if(!valid(n,a))return 0ll; sort(a,a+n); int i,res=1; for(i=0;i<n;i++){ if(a[i]<=n)continue; res=(res*pw(1ll*(n-i),1ll*(a[i]-max(n,(i>0?a[i-1]:0))-1)))%mod; } if(a[0]>n)res=(1ll*res*n)%mod; return res; }

Compilation message (stderr)

gondola.cpp:5:1: error: 'll' does not name a type
    5 | ll mod=1e9+7;
      | ^~
gondola.cpp:44:1: error: 'll' does not name a type
   44 | ll pw(ll a,ll b){
      | ^~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:56:18: error: 'pw' was not declared in this scope; did you mean 'pow'?
   56 |         res=(res*pw(1ll*(n-i),1ll*(a[i]-max(n,(i>0?a[i-1]:0))-1)))%mod;
      |                  ^~
      |                  pow
gondola.cpp:56:68: error: 'mod' was not declared in this scope; did you mean 'modf'?
   56 |         res=(res*pw(1ll*(n-i),1ll*(a[i]-max(n,(i>0?a[i-1]:0))-1)))%mod;
      |                                                                    ^~~
      |                                                                    modf
gondola.cpp:58:31: error: 'mod' was not declared in this scope; did you mean 'modf'?
   58 |     if(a[0]>n)res=(1ll*res*n)%mod;
      |                               ^~~
      |                               modf