제출 #592906

#제출 시각아이디문제언어결과실행 시간메모리
592906AQT카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; /* void allocate_tickets(vector<vector<int>> arr) { for(auto v : arr) { for(auto n : v) { cout << n << " "; } cout << "\n"; } } */ long long find_maximum(int K, vector<vector<int>> arr) { int N = arr.size(); int M = arr[0].size(); int G = M - K; long long ans = 0; vector<vector<int>> ret; vector<vector<int>> typ; ret.resize(N); typ.resize(N); priority_queue<pair<int, pair<int, int>>> pq; for(int i = 0; i < N; i++) { ret[i].resize(M, -1); typ[i].resize(M); for(int j = M - 1; j >= M - K; j--) { ans += arr[i][j]; pq.push(make_pair(-arr[i][j] - arr[i][j-G], make_pair(i, j))); typ[i][j] = 1; } } int tot = N * K / 2; while(tot--) { auto p = pq.top(); ans += p.first; typ[p.second.first][p.second.second] = 0; typ[p.second.first][p.second.second-G] = -1; pq.pop(); } vector<pair<int, int>> cnt(N); vector<int> tkn(N); for(int i = 0; i < N; i++) { int c = 0; for(int j = 0; j < M; j++) { if(typ[i][j] == 1) { c++; } } cnt.emplace_back(c, i); } for(int k = 0; k < K; k++) { sort(cnt.begin(), cnt.end()); for(int n = 0; n < N / 2; n++) { auto p = cnt[n]; ret[p.second][k - tkn[p.second]] = k; } for(int n = N/2; n < N; n++) { pair<int,int>& p = cnt[n]; tkn[p.second]++; ret[p.second][M-1-tkn[p.second]] = k; tkn[p.second]++; p.first--; } } allocate_tickets(ret); return ans; } int main(){ long long out = find_maximum(2, {{0, 2, 5},{1, 1, 3}}); }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:68:2: error: 'allocate_tickets' was not declared in this scope
   68 |  allocate_tickets(ret);
      |  ^~~~~~~~~~~~~~~~
tickets.cpp: In function 'int main()':
tickets.cpp:73:12: warning: unused variable 'out' [-Wunused-variable]
   73 |  long long out = find_maximum(2, {{0, 2, 5},{1, 1, 3}});
      |            ^~~