Submission #366935

#TimeUsernameProblemLanguageResultExecution timeMemory
366935wind_reaperCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans(n, vector<int>(m, -1)); int64_t a = 0; for(int i = 0; i < n; i++){ for(int j = m-1; j >= m-k; --j){ ans[i][j] = (m-1-j); a += int64_t(x[i][j]); } } vector<array<int64_t, 4>> b; for(int i = 0; i < n; i++){ for(int j = 1; j <= k; j++) b.push_back({x[i][k-j] + x[i][m-j], i, k-j, m-j}); } sort(b.rbegin(), b.rend()); for(int i = 0; i < (n*k)/2; i++){ int64_t red = b[i][0]; int row = b[i][1], mn = b[i][2], b[i][3]; a -= red; swap(ans[row][mx], ans[row][mn]); } allocate_tickets(ans); return a; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:34:18: error: 'mx' was not declared in this scope; did you mean 'mn'?
   34 |    swap(ans[row][mx], ans[row][mn]);
      |                  ^~
      |                  mn
tickets.cpp:32:37: warning: unused variable 'b' [-Wunused-variable]
   32 |    int row = b[i][1], mn = b[i][2], b[i][3];
      |                                     ^