제출 #301956

#제출 시각아이디문제언어결과실행 시간메모리
301956VEGAnn카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> #define PB push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define i2 array<int,2> #define i3 array<int,3> using namespace std; typedef long long ll; const int N = 1600; const ll OO = 1e18; vector<i3> vc; ll f[N][N]; int pre[N][N]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); fill(all(row), -1); answer.push_back(row); } if (k == m){ ll ans = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) vc.PB({a[i][j], i, j}); sort(all(vc)); for (int i = 0; i < sz(vc); i++) if (i < sz(vc) / 2) ans -= vc[i][0]; else ans += vc[i][0]; return ans; } for (int i = 0; i < n; i++) for (int j = 0; j <= n; j++) f[i][j] = -OO; f[0][0] = x[0][m - 1]; f[0][1] = -x[0][0]; int n2 = (n >> 1); for (int i = 0; i < n - 1; i++) for (int cnt = 0; cnt <= n2; cnt++){ if (f[i][cnt] == -OO) continue; if (cnt + 1 <= n2 && f[i][cnt] - x[i + 1][0] > f[i + 1][cnt + 1]){ f[i + 1][cnt + 1] = f[i][cnt] - x[i + 1][0]; pre[i + 1][cnt + 1] = cnt; } if (f[i][cnt] + x[i + 1][m - 1] > f[i + 1][cnt]){ f[i + 1][cnt] = f[i][cnt] + x[i + 1][m - 1]; pre[i + 1][cnt] = cnt; } } ll ans = f[n - 1][n2]; int i = n - 1, j = n2; while (i > 0){ int pr = pre[i][j]; if (j == pr){ answer[i][m - 1] = 0; } else { answer[i][0] = 0; } j = pr; i--; } if (j == 1){ answer[0][0] = 0; } else { answer[0][m - 1] = 0; } allocate_tickets(answer); return ans; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:35:20: error: 'a' was not declared in this scope
   35 |             vc.PB({a[i][j], i, j});
      |                    ^
tickets.cpp:35:34: error: no matching function for call to 'std::vector<std::array<int, 3> >::push_back(<brace-enclosed initializer list>)'
   35 |             vc.PB({a[i][j], i, j});
      |                                  ^
In file included from /usr/include/c++/9/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 3>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<int, 3>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 3>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<int, 3> >::value_type&&' {aka 'std::array<int, 3>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~