제출 #405120

#제출 시각아이디문제언어결과실행 시간메모리
405120ly20카니발 티켓 (IOI20_tickets)C++17
컴파일 에러
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> const int MAXN = 1512; int resp[MAXN]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector <int> d1; for(int i = 0; i < n; i++) { d1.push_back(x[i][0]); } sort(d1.begin(), d1.end()); long long md = d1[m/2]; long long resp = 0; for(int i = 0; i < n; i++) { if(d1[i] < md) resp += md - d1[i]; else resp += d1[i] - md; } vector <vector <int> > answer; vector <int> temp; for(int i = 0; i < n; i++) { temp.push_back(0); } answer.push_back(temp); allocate_tickets(answer); return resp; }

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

tickets.cpp:5:31: error: 'vector' has not been declared
    5 | long long find_maximum(int k, vector<vector<int>> x) {
      |                               ^~~~~~
tickets.cpp:5:37: error: expected ',' or '...' before '<' token
    5 | long long find_maximum(int k, vector<vector<int>> x) {
      |                                     ^
tickets.cpp: In function 'long long int find_maximum(int, int)':
tickets.cpp:6:10: error: 'x' was not declared in this scope
    6 |  int n = x.size();
      |          ^
tickets.cpp:8:2: error: 'vector' was not declared in this scope
    8 |  vector <int> d1;
      |  ^~~~~~
tickets.cpp:8:2: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
tickets.cpp:8:10: error: expected primary-expression before 'int'
    8 |  vector <int> d1;
      |          ^~~
tickets.cpp:10:9: error: 'd1' was not declared in this scope; did you mean 'y1'?
   10 |         d1.push_back(x[i][0]);
      |         ^~
      |         y1
tickets.cpp:12:7: error: 'd1' was not declared in this scope; did you mean 'y1'?
   12 |  sort(d1.begin(), d1.end());
      |       ^~
      |       y1
tickets.cpp:12:2: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   12 |  sort(d1.begin(), d1.end());
      |  ^~~~
      |  std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tickets.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
tickets.cpp:19:18: error: expected primary-expression before 'int'
   19 |  vector <vector <int> > answer;
      |                  ^~~
tickets.cpp:20:10: error: expected primary-expression before 'int'
   20 |  vector <int> temp;
      |          ^~~
tickets.cpp:22:9: error: 'temp' was not declared in this scope
   22 |         temp.push_back(0);
      |         ^~~~
tickets.cpp:24:2: error: 'answer' was not declared in this scope
   24 |  answer.push_back(temp);
      |  ^~~~~~
tickets.cpp:24:19: error: 'temp' was not declared in this scope
   24 |  answer.push_back(temp);
      |                   ^~~~