제출 #72868

#제출 시각아이디문제언어결과실행 시간메모리
72868nvmdava곤돌라 (IOI14_gondola)C++17
컴파일 에러
0 ms0 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; struct Gondola{ int id, int val; Gondola(int _id, int _val){ id = _id; val = _val; } bool operator<(const Gondola& rhs) const{ val < rhs.val; } }; int ord[100001]; map<int, int> in; vector<Gondola> v; int valid(int n, int inputSeq[]){ int i; for(i = 0; i < n; i++){ if(in[inputSeq[i]) return 0; in[inputSeq[i]] = 1; } for(i = 0; i < n; i++){ if(inputSeq[i] <= n) break; } if(i == n) return 1; int k = inputSeq[i] - 1; for(int j = 0; j < n; j++){ ord[(k + j) % n] = inputSeq[(i + j) % n]; if((ord[(k + j) % n] != (k + j) % n + 1 && ord[(k + j) % n] <= n) || ord[(k + j) % n] < 1) return 0; } for(i = 0; i < n; i++){ if((ord[i] != i + 1 && ord[i] <= n) || ord[i] < 1) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]){ for(i = 0; i < n; i++){ if(inputSeq[i] <= n) break; } int k; if(i == n){ i = 0; k = 0; } else { k = inputSeq[i] - 1; } for(int j = 0; j < n; j++){ ord[(k + j) % n] = inputSeq[(i + j) % n]; v.push_back(Gondola((k + j) % n, ), ord[(k + j) % n]); } sort(v.begin(), v.end()); i = 0; int s = n + 1; for(auto x : v){ if(x.val <= n) continue; for(; s < x.val; s++){ replacementSeq[i] = s; i++; } s = x.val + 1; } return i; } //---------------------- int countReplacement(int n, int inputSeq[]){ for(i = 0; i < n; i++){ if(inputSeq[i] <= n) break; } int k; if(i == n){ i = 0; k = 0; } else { k = inputSeq[i] - 1; } for(int j = 0; j < n; j++){ ord[(k + j) % n] = inputSeq[(i + j) % n]; } }

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

gondola.cpp:6:10: error: expected unqualified-id before 'int'
  int id, int val;
          ^~~
gondola.cpp: In constructor 'Gondola::Gondola(int, int)':
gondola.cpp:9:3: error: 'val' was not declared in this scope
   val = _val;
   ^~~
gondola.cpp:9:3: note: suggested alternative: '_val'
   val = _val;
   ^~~
   _val
gondola.cpp: In member function 'bool Gondola::operator<(const Gondola&) const':
gondola.cpp:12:3: error: 'val' was not declared in this scope
   val < rhs.val;
   ^~~
gondola.cpp:12:13: error: 'const struct Gondola' has no member named 'val'
   val < rhs.val;
             ^~~
gondola.cpp:13:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:24:20: error: expected ']' before ')' token
   if(in[inputSeq[i]) return 0;
                    ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:45:6: error: 'i' was not declared in this scope
  for(i = 0; i < n; i++){
      ^
gondola.cpp:46:6: error: 'inputSeq' was not declared in this scope
   if(inputSeq[i] <= n) break;
      ^~~~~~~~
gondola.cpp:49:5: error: 'i' was not declared in this scope
  if(i == n){
     ^
gondola.cpp:53:7: error: 'inputSeq' was not declared in this scope
   k = inputSeq[i] - 1; 
       ^~~~~~~~
gondola.cpp:56:22: error: 'inputSeq' was not declared in this scope
   ord[(k + j) % n] = inputSeq[(i + j) % n];
                      ^~~~~~~~
gondola.cpp:56:32: error: 'i' was not declared in this scope
   ord[(k + j) % n] = inputSeq[(i + j) % n];
                                ^
gondola.cpp:57:22: error: expected primary-expression before '(' token
   v.push_back(Gondola((k + j) % n, ), ord[(k + j) % n]);
                      ^
gondola.cpp:57:36: error: expected primary-expression before ')' token
   v.push_back(Gondola((k + j) % n, ), ord[(k + j) % n]);
                                    ^
gondola.cpp:60:2: error: 'i' was not declared in this scope
  i = 0;
  ^
gondola.cpp:63:8: error: 'struct Gondola' has no member named 'val'
   if(x.val <= n) continue;
        ^~~
gondola.cpp:64:15: error: 'struct Gondola' has no member named 'val'
   for(; s < x.val; s++){
               ^~~
gondola.cpp:68:9: error: 'struct Gondola' has no member named 'val'
   s = x.val + 1;
         ^~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:76:6: error: 'i' was not declared in this scope
  for(i = 0; i < n; i++){
      ^
gondola.cpp:80:5: error: 'i' was not declared in this scope
  if(i == n){
     ^
gondola.cpp:87:32: error: 'i' was not declared in this scope
   ord[(k + j) % n] = inputSeq[(i + j) % n];
                                ^
gondola.cpp:89:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^