Submission #308110

#TimeUsernameProblemLanguageResultExecution timeMemory
308110juggernautGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include"gondola.h" #include<bits/stdc++.h> //#include"grader.cpp" using namespace std; typedef long long int ll; 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 1ll; if(b&1)return (a*pw(a,b-1))%mod; ll x=pw(a,b>>1ll); return (x*x)%mod; } ll countReplacement(int n,ll a[]){ if(!valid(n,a))return 0; sort(a,a+n); ll i,res=1; for(i=0;i<n;i++){ if(a[i]<=n)continue; res=(res*pw(n-i,a[i]-max(n,(i>0?a[i-1]:0))-1))%mod; } if(a[0]>n)res=(res*n)%mod; return res; }

Compilation message (stderr)

gondola.cpp: In function 'll countReplacement(int, ll*)':
gondola.cpp:52:17: error: cannot convert 'll*' {aka 'long long int*'} to 'int*'
   52 |     if(!valid(n,a))return 0;
      |                 ^
      |                 |
      |                 ll* {aka long long int*}
gondola.cpp:7:21: note:   initializing argument 2 of 'int valid(int, int*)'
    7 | int valid(int n,int a[]){
      |                 ~~~~^~~
gondola.cpp:57:50: error: no matching function for call to 'max(int&, long long int)'
   57 |         res=(res*pw(n-i,a[i]-max(n,(i>0?a[i-1]:0))-1))%mod;
      |                                                  ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from gondola.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
gondola.cpp:57:50: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   57 |         res=(res*pw(n-i,a[i]-max(n,(i>0?a[i-1]:0))-1))%mod;
      |                                                  ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from gondola.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
gondola.cpp:57:50: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   57 |         res=(res*pw(n-i,a[i]-max(n,(i>0?a[i-1]:0))-1))%mod;
      |                                                  ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from gondola.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
gondola.cpp:57:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |         res=(res*pw(n-i,a[i]-max(n,(i>0?a[i-1]:0))-1))%mod;
      |                                                  ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from gondola.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
gondola.cpp:57:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |         res=(res*pw(n-i,a[i]-max(n,(i>0?a[i-1]:0))-1))%mod;
      |                                                  ^