제출 #403902

#제출 시각아이디문제언어결과실행 시간메모리
403902Iwanttobreakfree곤돌라 (IOI14_gondola)C++98
컴파일 에러
0 ms0 KiB
#include "gondola.h" #include <vector> 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(inputSeq[i]>maxi){ maxi=inputSeq; } } set<int> s; for(int i=1;i<=maxi;i++){ s.insert(i); } for(int i=0;i<n;i++){ s.erase(inputSeq[i]); } int cont=0; for(int x:s){ replacementSeq[cont]=x; cont++; } return cont; } int countReplacement(int n, int inputSeq[]){ return -3; }

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:35:5: error: 'inputSeq' was not declared in this scope
   35 |  if(inputSeq[i]>maxi){
      |     ^~~~~~~~
gondola.cpp:39:3: error: 'set' was not declared in this scope
   39 |   set<int> s;
      |   ^~~
gondola.cpp:3:1: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
    2 | #include <vector>
  +++ |+#include <set>
    3 | using namespace std;
gondola.cpp:39:7: error: expected primary-expression before 'int'
   39 |   set<int> s;
      |       ^~~
gondola.cpp:41:4: error: 's' was not declared in this scope
   41 |    s.insert(i);
      |    ^
gondola.cpp:44:4: error: 's' was not declared in this scope
   44 |    s.erase(inputSeq[i]);
      |    ^
gondola.cpp:44:12: error: 'inputSeq' was not declared in this scope
   44 |    s.erase(inputSeq[i]);
      |            ^~~~~~~~
gondola.cpp:47:13: error: 's' was not declared in this scope
   47 |   for(int x:s){
      |             ^