Submission #577406

#TimeUsernameProblemLanguageResultExecution timeMemory
577406perchutsGondola (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define pb push_back #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; using ll = long long; using ull = unsigned long long; using ii = pair<int,int>; using iii = tuple<int,int,int>; const int inf = 2e9+1; const int mod = 1e9+9; const int maxn = 1e5+100; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } #include "gondola.h" int valid(int n,int v[]){ vector<ii>v2; map<int,bool>mp; int mn = inf, idx = -1; for(int i=0;i<n;++i){ if(mp[v[i]]==1)return 0; mp[v[i]] = 1; if(ckmin(mn,v[i]))idx = i; } if(mn>=n)return 1; for(int i=idx;i<n;++i)if(v[i]<=n)v2.pb({v[i],i-idx}); for(int i=0;i<idx;++i)if(v[i]<=n)v2.pb({v[i],n-idx+i}); for(int i=1;i<sz(v2);++i){ if(v2[i].first-v2[i-1].first!=v2[i].second-v2[i-1].second)return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { priority_queue<ii,vector<ii>,greater<ii>>pq; int mn = inf, idx = 0; for(int i=0;i<n;++i)if(ckmin(mn,gondolaSeq[i]))idx = i; for(int i=(idx+1)%n;i!=idx;i=(i+1)%n){ if(mn>n)mn = 0; pq.push({gondolaSeq[i],++mn}); } idx = 0; while(!pq.empty()){ auto [target,current] = pq.top();pq.pop(); if(target==current)continue; replacementSeq[idx++] = current++; pq.push({target,current}); } return idx; } //---------------------- ll fastexp(ll b,ll e){ if(e==0)return 1ll; if(e==1)return b; ll sqr = fastexp(b,e/2), resp = (sqr*sqr)%mod; if(e&1)return (resp*b)%mod; return resp; } int countReplacement(int n, int inputSeq[]) { vector<int>big; if(!valid(n,inputSeq))return 0; for(int i=0;i<n;++i){ if(inputSeq[i]>n)big.pb(inputSeq[i]); } sort(all(big)); ll res = 1, last = n; for(int i=0;i<sz(big);++i){ res = res*fastexp(sz(big)-i,big[i]-last-1); res %= mod, last = big[i]; } return res; } int v[maxn]; int main(){_ int n;cin>>n; for(int i=0;i<n;++i)cin>>v[i]; cout<<countReplacement(n,v)<<endl; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccFY8Zty.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccAZ1Tbw.o:gondola.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status