Submission #928069

#TimeUsernameProblemLanguageResultExecution timeMemory
928069EJIC_B_KEDAXCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" using ll = long long; using namespace std; int64_t 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; res += abs(a[i][j]); a[i].first += t[i][j]; } } for (int r = 0; r < k; r++) { sort(a.begin(), a.end()); for (int i = 0; i < n / 2; i++) { a[i].first -= t[a[i].second][bg[a[i].second]]; s[a[i].second][bg[a[i].second]++] = r; } for (int i = n / 2; i < n; i++) { a[i].first -= t[a[i].second][end[a[i].second]]; s[a[i].second][end[a[i].second]--] = r; } } allocate_tickets(s); return res; }

Compilation message (stderr)

tickets.cpp:8:9: error: ambiguating new declaration of 'int64_t find_maximum(int, std::vector<std::vector<int> >)'
    8 | int64_t find_maximum(int k, vector<vector<int>> t) {
      |         ^~~~~~~~~~~~
In file included from tickets.cpp:2:
tickets.h:3:11: note: old declaration 'long long int find_maximum(int, std::vector<std::vector<int> >)'
    3 | long long find_maximum(int k, std::vector<std::vector<int>> d);
      |           ^~~~~~~~~~~~
tickets.cpp: In function 'int64_t find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:27:28: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, int> >, std::pair<long long int, int> >::value_type' {aka 'std::pair<long long int, int>'} and 'int')
   27 |             res += abs(a[i][j]);
      |                            ^