제출 #928091

#제출 시각아이디문제언어결과실행 시간메모리
928091EJIC_B_KEDAX카니발 티켓 (IOI20_tickets)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" using ll = long long; using namespace std; ll find_maximum(int k, vector<vector<int>> t) { int n = t.size(), m = t[0].size(); vector<int> all; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { all.push_back(t[i][j]); } } sort(all.begin(), all.end()); int middle = all[all.size() / 2]; ll res = 0; vector<pair<ll, int>> a(n); vector<int> bg(n, 0), end(n, m - 1); vector<vector<int>> s(n, vector<int>(m, -1)); for (int i = 0; i < n; i++) { a[i].first = 0; a[i].second = i; for (int j = 0; j < m; j++) { t[i][j] -= middle; } } for (int st = 0; st < k; st++) { vector<pair<int, int>> l, r; for (int i = 0; i < n; i++) { if (abs(t[i][bg[i]]) > abs(t[i][end[i]])) { if (t[i][end[i]] < 0) { l.emplace_back(INT32_MAX, i); } else { l.emplace_back(abs(abs(t[i][bg[i]]) - abs(t[i][end[i]])), i); } } else { if (t[i][bg[i]] > 0) { l.emplace_back(INT32_MAX, i); } else { l.emplace_back(abs(abs(t[i][bg[i]]) - abs(t[i][end[i]])), i); } } } sort(l.begin(), l.end(), greater<>()); sort(r.begin(), r.end(), greater<>()); for (auto [w, i] : l) { li.insert(i); } for (auto [w, i] : r) { ri.insert(i); } set<int> li, ri; while (l.size() > n / 2) { li.erase(l.back().second); ri.insert(l.back().second); l.pop_back(); } while (r.size() > n / 2) { ri.erase(r.back().second); li.insert(r.back().second); r.pop_back(); } vector<int> nw; for (int i : li) { s[i][bg[i]] = st; nw.push_back(t[i][bg[i]++]); } for (int i : ri) { s[i][end[i]] = st; nw.push_back(t[i][end[i]--]); } sort(nw.begin(), nw.end()); for (int i : nw) { ans += abs(i); } assert(0 >= nw[n / 2 - 1] && 0 <= nw[n / 2]); } allocate_tickets(s); return res; }

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:49:13: error: 'li' was not declared in this scope; did you mean 'i'?
   49 |             li.insert(i);
      |             ^~
      |             i
tickets.cpp:52:13: error: 'ri' was not declared in this scope; did you mean 'i'?
   52 |             ri.insert(i);
      |             ^~
      |             i
tickets.cpp:55:25: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |         while (l.size() > n / 2) {
      |                ~~~~~~~~~^~~~~~~
tickets.cpp:60:25: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |         while (r.size() > n / 2) {
      |                ~~~~~~~~~^~~~~~~
tickets.cpp:76:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   76 |             ans += abs(i);
      |             ^~~
      |             abs