Submission #1306575

#TimeUsernameProblemLanguageResultExecution timeMemory
1306575witek_cppCarnival Tickets (IOI20_tickets)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define f(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) f(i, 0, a)
#define tv(a, x) for (auto& a : x)
#define DUZO 1000000000000000000LL
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

/*void allocate_tickets(vvi ans) {
    int n = sz(ans);
    int m = sz(ans[0]);
    cout << "moja odpowiedz to:\n";
    rep(i, n) {
        rep(j, m) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
}*/

ll find_maximum(int k, vvi x) {
    int n = sz(x);
    int m = sz(x[0]);
    vvi ans(n, vi(m));
    int wnk = 0;
    rep(i, n) {
        rep(j, m) ans[i][j] = -1;
    }
    vi wsk_r(n, m - 1);
    vi wsk_l(n, 0);
    rep(_, k) {
        vector<pii> p1(n);
        rep(i, n) {
            p1[i] = {x[i][wsk_l[i]] + x[i][wsk_r[i]], i};
        }
        sort(all(p1));
        vi uzyte;
        rep(i, (n/2)) {
            int ind = p1[i].nd;
            ans[ind][wsk_l[ind]] = _;
            uzyte.pb(x[ind][wsk_l[ind]]);
            wsk_l[ind]++;
        }
        f(i, (n/2), n) {
            int ind = p1[i].nd;
            ans[ind][wsk_r[ind]] = _;
            uzyte.pb(x[ind][wsk_r[ind]]);
            wsk_r[ind]++;
        }
        sort(all(uzyte));
        int med = (uzyte[n/2] + uzyte[(n/2) - 1])/2;
        tv(x, uzyte) wnk += abs(med - x);
    }
    allocate_tickets(ans);
    return wnk;
}

/*int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k = 2;
    //[[0, 2, 5],[1, 1, 3]]
    vvi x = {{0, 2, 5}, {1, 1, 3}};
}*/

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, vvi)':
tickets.cpp:64:5: error: 'allocate_tickets' was not declared in this scope
   64 |     allocate_tickets(ans);
      |     ^~~~~~~~~~~~~~~~