Submission #389154

#TimeUsernameProblemLanguageResultExecution timeMemory
389154apostoldaniel854Gondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define HOME #ifndef HOME #include "gondola.h" #endif // HOME int valid(int n, int inputSeq[]) { int mn = 0; map <int, int> freq; for (int i = 0; i < n; i++) { if (inputSeq[i] < inputSeq[mn]) mn = i; freq[inputSeq[i]]++; if (freq[inputSeq[i]] > 1) return 0; } rotate (inputSeq, inputSeq + mn, inputSeq + n); int val = inputSeq[0]; for (int i = 0; i < n; i++) { if (inputSeq[i] <= n) { if (val != inputSeq[i]) return 0; } val++; } return 1; } //---------------------- const int max_n = 25e4; int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int mn = 0; for (int i = 0; i < n; i++) { if (gondolaSeq[i] < gondolaSeq[mn]) mn = i; } if (gondolaSeq[mn] <= n) rotate (gondolaSeq, gondolaSeq + (n + mn - gondolaSeq[mn] + 1) % n, gondolaSeq + n); int l = 0; vector <int> pos (1 + max_n); int mx = 0; for (int i = 0; i < n; i++) { pos[gondolaSeq[i]] = i + 1; if (gondolaSeq[i] > gondolaSeq[mx]) mx = i; } int valmax = gondolaSeq[mx]; int cur = mx + 1; for (int i = n + 1; i <= valmax; i++) { if (i == valmax || pos[i] == 0) replacementSeq[l++] = cur, cur = i; else replacementSeq[l++] = pos[i]; } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; } #ifdef HOME int gondolaSequence[100001]; int replacementSequence[250001]; int main() { int i, n, tag; int nr; assert(scanf("%d", &tag)==1); assert(scanf("%d", &n)==1); for(i=0;i< n;i++) assert( scanf("%d", &gondolaSequence[i]) ==1); switch (tag){ case 1: case 2: case 3: printf("%d\n", valid(n, gondolaSequence)); break; case 4: case 5: case 6: nr = replacement(n, gondolaSequence, replacementSequence); printf("%d ", nr); if (nr > 0) { for (i=0; i<nr-1; i++) printf("%d ", replacementSequence[i]); printf("%d\n", replacementSequence[nr-1]); } else printf("\n"); break; case 7: case 8: case 9: case 10: printf("%d\n", countReplacement(n, gondolaSequence)); break; } return 0; } #endif // HOME /** 4 2 3 2 **/

Compilation message (stderr)

/tmp/cc7DNmzG.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc2bMgx3.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/cc7DNmzG.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/cc2bMgx3.o:(.bss+0xf4260): first defined here
/tmp/cc7DNmzG.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/cc2bMgx3.o:(.bss+0x0): first defined here
/tmp/cc7DNmzG.o: In function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status