Submission #138727

#TimeUsernameProblemLanguageResultExecution timeMemory
138727Mahmoud_AdelGondola (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 ll; const int N = 1e6+5, mod = 1e9+7; int mark[N], mep[N]; int valid(int n, int inputSeq[]) { for(int i=0; i<n; i++) { if(mark[inputSeq[i]]) return 0; else mark[inputSeq[i]] = 1; } int j = -1; for(int i=0; i<n; i++) if(inputSeq[i] > 0 && inputSeq[i] <= n) j = i; if(j == -1) return 1; for(int i=0; i<n; i++) { int id = (i+j)%n, jd = (i+j+1)%n; if(inputSeq[jd] > n) inputSeq[jd] = inputSeq[id]%n + 1; if(inputSeq[jd] != inputSeq[id]%n + 1) return 0; } return 1; } //---------------------- int replacement(int n, int inputSeq[], int replacementSeq[]) { memset(mep, 0, sizeof mep); int j = -1, c = n; for(int i=0; i<n; i++) if(inputSeq[i] <= n) j = i; if(j == -1) { for(int i=0; i<n; i++) replacementSeq[inputSeq[i]-n-1] = i+1; return n; } for(int i=0; i<n; i++) { int id = (i+j) % n, jd = (i+j+1) % n; if(inputSeq[jd] > n) c = max(c, inputSeq[jd]), mep[inputSeq[jd]] = inputSeq[id]%n + 1, inputSeq[jd] = inputSeq[id]%n + 1; } int last = -1; for(int i=c; i>n; i--) { if(mep[i] && last == -1) last = i; if(!mep[i]) replacementSeq[i-n-1] = replacementSeq[last-n-1], replacementSeq[last-n-1] = i; else replacementSeq[i-n-1] = mep[i]; } return c-n; } //---------------------- int countReplacement(int n, int inputSeq[]) { int tmp[n]; for(int i=0; i<n; i++) tmp[i] = inputSeq[i]; if(!valid(n, inputSeq)) return 0; for(int i=0; i<n; i++) inputSeq[i] = tmp[i]; memset(mep, 0, sizeof mep); ll j = -1, c = n; for(int i=0; i<n; i++) if(inputSeq[i] <= n) j = i; if(j == -1) { for(int i=0; i<n; i++) { c = max(c, (ll)inputSeq[i]); mep[inputSeq[i]] = 1; } ll cnt = 1, cmt=0; for(ll i=c; i>n; i--) { if(!mep[i]) cnt *= (cmt), cnt %= mod; else cmt++; } return (cnt*n)%mod; } for(int i=0; i<n; i++) { ll id = (i+j) % n, jd = (i+j+1) % n; if(inputSeq[jd] > n) c = max(c, (ll)inputSeq[jd]), mep[inputSeq[jd]] = inputSeq[id]%n + 1, inputSeq[jd] = inputSeq[id]%n + 1; } ll cnt = 1, cmt=0; if(!c) cnt = 0; for(ll i=c; i>n; i--) { if(!mep[i]) cnt *= cmt, cnt %= mod; else cmt++; } return cnt; }

Compilation message (stderr)

/tmp/ccCLJU9I.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccoeg85b.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccCLJU9I.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/ccoeg85b.o:(.bss+0x8954a0): first defined here
/tmp/ccCLJU9I.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/ccoeg85b.o:(.bss+0x7a1240): first defined here
collect2: error: ld returned 1 exit status