Submission #232073

#TimeUsernameProblemLanguageResultExecution timeMemory
232073anonymousGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include "gondola.h" #include <vector> #include <iostream> #define MAXN 100005 #define MAXV 250005 using namespace std; int valid(int n, int Seq[]) { bool has[MAXV]={}, b = false; int pos, v; for (int i=0; i<n; i++) { if (Seq[i] <= n) { pos = i; v = Seq[i]; } if (has[Seq[i]]) {return(0);} has[Seq[i]]=true; } for (int i=0; i<n; i++) { if (Seq[pos] > n) {} else if (Seq[pos] != v) {return(0);} pos = (pos+1) %n; v= v == n ? 1 : v+1; } return(1); } //---------------------- int replacement(int n, int Seq[], int ans[]) { int mx = 0, first=0, pos[MAXV]={}, Cur[MAXN]; bool b = false; for (int i=0; i<n; i++) { if (Seq[i] > n) { pos[Seq[i]] = i+1; if (!first) {first = i+1;} } else if (!b) { int p = i+1, v = Seq[i]; for (int j=0; j<n; j++) { Cur[p] = v; p = p == n ? 1: p+1; v = v == n ? 1: v+1; } b=true; } mx = max(mx, Seq[i]); } if (!b) { for (int i=1; i<=n; i++) {Cur[i] = i;} } for (int i=n+1; i<=mx; i++) { if (pos[i] == 0) { ans[i - n - 1] = Cur[first]; Cur[first] = i; } else { ans[i - n - 1] = Cur[pos[i]]; Cur[pos[i]] = i; while (Cur[first] == Seq[first-1]) {first++;} } } return(mx - n); }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:10:22: warning: unused variable 'b' [-Wunused-variable]
   bool has[MAXV]={}, b = false;
                      ^
gondola.cpp:25:15: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
     v= v == n ? 1 : v+1;
        ~~~~~~~^~~~~~~~~
gondola.cpp:22:16: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (Seq[pos] > n) {}
                ^
/tmp/ccPtkc6I.o: In function `main':
grader.cpp:(.text.startup+0xc3): undefined reference to `countReplacement'
collect2: error: ld returned 1 exit status