Submission #403907

#TimeUsernameProblemLanguageResultExecution timeMemory
403907IwanttobreakfreeGondola (IOI14_gondola)C++98
15 / 100
12 ms1472 KiB
#include "gondola.h" #include <vector> #include <set> using namespace std; int valid(int n, int inputSeq[]){ int mini=1e9,pos,cont=0; for(int i=0;i<n;i++){ if(inputSeq[i]<mini){ mini=inputSeq[i]; pos=i; } } vector<bool> visto(n,false); vector<int>v(n); for(int i=pos;i<n;i++){ v[cont]=inputSeq[i]; cont++; } for(int i=0;i<pos;i++){ v[cont]=inputSeq[i]; cont++; } for(int i=0;i<n;i++){ if(v[i]>n){ if(!visto[v[i]])visto[v[i]]=true; else return 0; } if(v[i]-mini!=i)return 0; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ int maxi=0; for(int i=0;i<n;i++){ if(gondolaSeq[i]>maxi){ maxi=gondolaSeq[i]; } } set<int> s; for(int i=1;i<=maxi;i++){ s.insert(i); } for(int i=0;i<n;i++){ s.erase(gondolaSeq[i]); } int cont=0; for(int x:s){ replacementSeq[cont]=x; cont++; } return cont; } int countReplacement(int n, int inputSeq[]){ return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:11: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |    v[cont]=inputSeq[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...