Submission #445586

#TimeUsernameProblemLanguageResultExecution timeMemory
445586AlexRex0Gondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include <stdio.h> #include <assert.h> //#include "gondola.h" #include <bits/stdc++.h> using namespace std; set<int> existe; int valid(int n, int inputSeq[]) { int valido = 1, inicio = -1, valor = INT_MAX; for(int i = 0; i < n; ++i){ if(inputSeq[i] <= n && inputSeq[i] < valor){ inicio = i; valor = inputSeq[i]; } if(existe.count(inputSeq[i]) != 0){ valido = 0; } existe.insert(inputSeq[i]); } if(inicio != -1){ valor++; for(int i = inicio + 1; i < n; ++i){ if(inputSeq[i] <= n && inputSeq[i] != valor){ valido = 0; } valor++; } for(int i = 0; i < inicio; ++i){ if(inputSeq[i] <= n && inputSeq[i] != valor){ valido = 0; } valor++; } } return valido; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return -1; } //---------------------- bool fijo[250002]; long long int acumulado[250002]; long long int original[250002]; long long int aux, pos = -1, res = 1, suma; int countReplacement(int n, int inputSeq[]) { for(int i = 0; i < n; ++i){ if(inputSeq[i] <= n){ aux = inputSeq[i]; pos = i; break; } } if(pos == -1){ aux = 1; for(int i = 0; i < n; ++i){ original[i] = aux; aux++; } res*= n; res%= 1000000009; }else{ while(aux > 1){ aux--; pos--; if(pos == -1){ pos = n - 1; } } for(int i = pos; i < n; ++i){ original[i] = aux; aux++; } for(int i = 0; i < pos; ++i){ original[i] = aux; aux++; } } for(int i = 0; i < n; ++i){ fijo[inputSeq[i]] = true; fijo[original[i]] = true; acumulado[original[i]]++; acumulado[inputSeq[i] + 1]--; } for(int i = 1; i <= 250000; ++i){ suma+= acumulado[i]; if(!fijo[i]){ if(suma > 0){ res*= suma; } res%= 1000000009; } } return res; } 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; }

Compilation message (stderr)

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