제출 #110109

#제출 시각아이디문제언어결과실행 시간메모리
110109SirCeness자리 배치 (IOI18_seats)C++14
컴파일 에러
0 ms0 KiB
#include "seats.h" int h, w; vector<int> r, c; void maxi(int& a, int b){ a = max(a, b); } void mini(int& a, int b){ a = min(a, b); } int getans(){ int rmax = r[0]; int rmin = r[0]; int cmax = c[0]; int cmin = c[0]; //cout << rmax << " " << rmin << " - " << cmax << " " << cmin << endl; int ans = 1; for (int i = 1; i < h*w; i++){ maxi(rmax, r[i]); mini(rmin, r[i]); maxi(cmax, c[i]); mini(cmin, c[i]); //cout << rmax << " " << rmin << " - " << cmax << " " << cmin << endl; if ((rmax-rmin+1)*(cmax-cmin+1) == i+1) ans++; } return ans; } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { h = H; w = W; for (int i = 0; i < h*w; i++){ r.push_back(R[i]); c.push_back(C[i]); } } int swap_seats(int a, int b) { int tmp = r[a]; r[a] = r[b]; r[b] = tmp; tmp = c[a]; c[a] = c[b]; c[b] = tmp; return getans(); }

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

seats.cpp:4:1: error: 'vector' does not name a type
 vector<int> r, c;
 ^~~~~~
seats.cpp: In function 'void maxi(int&, int)':
seats.cpp:8:6: error: 'max' was not declared in this scope
  a = max(a, b);
      ^~~
seats.cpp:8:6: note: suggested alternative:
In file included from /usr/include/c++/7/vector:60:0,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   'std::max'
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
seats.cpp: In function 'void mini(int&, int)':
seats.cpp:12:6: error: 'min' was not declared in this scope
  a = min(a, b);
      ^~~
seats.cpp:12:6: note: suggested alternative:
In file included from /usr/include/c++/7/vector:60:0,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   'std::min'
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
seats.cpp: In function 'int getans()':
seats.cpp:16:13: error: 'r' was not declared in this scope
  int rmax = r[0];
             ^
seats.cpp:18:13: error: 'c' was not declared in this scope
  int cmax = c[0];
             ^
seats.cpp: At global scope:
seats.cpp:33:39: error: 'vector' has not been declared
 void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
                                       ^~~~~~
seats.cpp:33:45: error: expected ',' or '...' before '<' token
 void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
                                             ^
seats.cpp: In function 'void give_initial_chart(int, int, int)':
seats.cpp:37:3: error: 'r' was not declared in this scope
   r.push_back(R[i]);
   ^
seats.cpp:37:15: error: 'R' was not declared in this scope
   r.push_back(R[i]);
               ^
seats.cpp:38:3: error: 'c' was not declared in this scope
   c.push_back(C[i]);
   ^
seats.cpp:38:15: error: 'C' was not declared in this scope
   c.push_back(C[i]);
               ^
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:43:12: error: 'r' was not declared in this scope
  int tmp = r[a];
            ^
seats.cpp:46:8: error: 'c' was not declared in this scope
  tmp = c[a];
        ^