Submission #441262

#TimeUsernameProblemLanguageResultExecution timeMemory
441262Christopher_RdzGondola (IOI14_gondola)C++14
20 / 100
10 ms716 KiB
#include "gondola.h" #include <assert.h> #include <stdio.h> #include <bits/stdc++.h> using namespace std; bool visited[250001]; struct dato{ int valor; int pos; }; bool operator <(const dato &a, const dato &b){ return a.valor < b.valor; } dato gon[250001]; int valid(int n, int inputSeq[]) { int index, aux, valor = 1; for (int i = 0; i < n; i++){ aux = inputSeq[i]; if (aux <= n){ index = i; valor = aux; break; } } for (int i = index; i < n + index; i++){ if (visited[ inputSeq[i % n] ]) return 0; visited[ inputSeq[i % n] ] = true; if (inputSeq[i % n] > n){ valor = (valor % n) + 1; continue; } if (inputSeq[i % n] != valor) return 0; valor = (valor % n) + 1; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int index, aux, valor = 1, L = 0, g = n + 1; for (int i = 0; i < n; i++){ aux = gondolaSeq[i]; if (aux <= n){ index = i; valor = aux; break; } } int pos = 0; for (int i = index; i < n + index; i++){ aux = gondolaSeq[i % n]; if (aux > n ){ gon[pos].valor = aux; gon[pos].pos = valor; valor = (valor % n) + 1; pos++; } } sort (gon + 0, gon + pos); for (int i = 0; i < pos; i++){ replacementSeq[L] = gon[i].pos; L++; while (g < gon[i].valor){ replacementSeq[L] = g; g++; L++; } g++; } return L; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:32:31: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |     for (int i = index; i < n + index; i++){
      |                             ~~^~~~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:59:31: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |     for (int i = index; i < n + index; i++){
      |                             ~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...