제출 #478768

#제출 시각아이디문제언어결과실행 시간메모리
478768khoabright카니발 티켓 (IOI20_tickets)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long #define ff first #define ss second #define pii pair<int, int> #define all(x) x.begin(), x.end() #define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i) #define mp make_pair #define vii vector<vector<int>> #define ll long long const int N = 2e5 + 5; const ll inf = 1e15; void allocate_tickets(vii a) { // int n = a.size(), m = a[0].size(); // rep(i, 0, n - 1) { // rep(j, 0, m - 1) { // cout << a[i][j] << ' '; // } // cout << '\n'; // } } struct ticket{ int color, value; }; bool operator < (const ticket &x, const ticket &y) { return x.value < y.value; } ll find_maximum(int k, vii a) { function<int()> sub1 = [&]() { int n = a.size(); vector<int> v(n); rep(i, 0, n - 1) v[i] = a[i][0]; sort(all(v)); int bound = v[n / 2]; int prize = 0; rep(i, 0, n - 1) prize += abs(v[i] - bound); rep(i, 0, n - 1) a[i][0] = 0; allocate_tickets(a); return prize; }; function<int()> sub2 = [&]() { int n = a.size(), m = a[0].size(); vii allo(n, vector<int> (m)); ll prize = 0; vector<ticket> Replace(n); vector<pair<pii, pii>> mima(n); //{min, max} rep(i, 0, n - 1) { pii maxi = {-1, -1}, mini = {inf, inf}; rep(j, 0, m - 1) { maxi = max(maxi, {a[i][j], j}); mini = min(mini, {a[i][j], j}); } mima[i] = {mini, maxi}; prize += maxi.ff; allo[i][maxi.ss] = 1; ticket tmp; tmp.color = i, tmp.value = mini.ff + maxi.ff; Replace[i] = tmp; } sort(all(Replace)); rep(i, 0, n / 2 - 1) { auto [color, value] = Replace[i]; //cout<<"color,value,mima="<<' '<<color<<' '<<value<<' '<<mima[i].ff.ss<<' '<<mima[i].ss.ss<<'\n'; allo[color][mima[i].ff.ss] = 1; allo[color][mima[i].ss.ss] = 0; prize -= value; } rep(i, 0, n - 1) rep(j, 0, m - 1) --allo[i][j]; allocate_tickets(allo); return prize; }; return sub2(); } // signed main() { // int n, m, k; cin >> n >> m >> k; // vii a(n, vector<int> (m)); // rep(i, 0, n - 1) rep(j, 0, m - 1) cin >> a[i][j]; // cout << find_maximum(k, a); // }

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

/usr/bin/ld: /tmp/ccuk483v.o: in function `allocate_tickets(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
grader.cpp:(.text+0x260): multiple definition of `allocate_tickets(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'; /tmp/ccISaK2x.o:tickets.cpp:(.text+0x7a0): first defined here
collect2: error: ld returned 1 exit status