Submission #319622

#TimeUsernameProblemLanguageResultExecution timeMemory
319622tevdoreCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" #define ll long long using namespace std; const int N = 2e3 + 10; ll find_maximum(int k, vector < vector < int > > x) { priority_queue < pair < int, int > > pq; vector < pair < int, int > > p[N]; stack < int > st[N]; stack < int > a[N]; int n = x.size(); int m = x[0].size(); ll res = 0; for(int i = 0; i < n; i++) { p[i].second = i; for(int j = m - 1; j >= m - k; j--) { st[i].push(x[i][j]); res += st[i].top(); } for(int j = m - 1; j >= 0; j--) a[i].push(x[i][j]); if(st[i].size() && a[i].size()) pq.push({a[i].top()- st[i].top(), i}); } vector < vector < int > > l; vector < vector < int > > r; for(int i = 0; i < n * k / 2; i++) { int f = pq.top().first; int s = pq.top().second; pq.pop(); res += f; p[s].first++; st[s].pop(); a[s].pop(); if(st[s].size() && a[s].size()) pq.push({a[s].top()- st[s].top(), s}); } vector < vector < int > > vr(n, vector < int > (m, -1)); for(int i = 0; i < n; i++) { for(int j = 0; j < p[i].first; j++) l[i].push_back(j); for(int j = m - (k - p[i].first); j < m; j++) r[i].push_back(j); } for(int i = 0; i < n; i++) { sort(p.rbegin(), p.rend()); for(int j = 0; j < n / 2; j++) { vr[p[j].second][l[p[j].second].back()] = i; p[j].first--; l[p[j].second].pop_back(); } for(int j = n / 2; j < n; j++) { vr[p[j].second][r[p[j].second].back()] = i; r[p[j].second].pop_back(); } } allocate_tickets(vr); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:15:14: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   15 |         p[i].second = i;
      |              ^~~~~~
tickets.cpp:30:14: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'first'
   30 |         p[s].first++;
      |              ^~~~~
tickets.cpp:37:33: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'first'
   37 |         for(int j = 0; j < p[i].first; j++) l[i].push_back(j);
      |                                 ^~~~~
tickets.cpp:38:35: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'first'
   38 |         for(int j = m - (k - p[i].first); j < m; j++) r[i].push_back(j);
      |                                   ^~~~~
tickets.cpp:41:16: error: request for member 'rbegin' in 'p', which is of non-class type 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > [2010]'
   41 |         sort(p.rbegin(), p.rend());
      |                ^~~~~~
tickets.cpp:41:28: error: request for member 'rend' in 'p', which is of non-class type 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > [2010]'
   41 |         sort(p.rbegin(), p.rend());
      |                            ^~~~
tickets.cpp:43:21: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   43 |             vr[p[j].second][l[p[j].second].back()] = i;
      |                     ^~~~~~
tickets.cpp:43:36: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   43 |             vr[p[j].second][l[p[j].second].back()] = i;
      |                                    ^~~~~~
tickets.cpp:44:18: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'first'
   44 |             p[j].first--;
      |                  ^~~~~
tickets.cpp:45:20: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   45 |             l[p[j].second].pop_back();
      |                    ^~~~~~
tickets.cpp:48:21: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   48 |             vr[p[j].second][r[p[j].second].back()] = i;
      |                     ^~~~~~
tickets.cpp:48:36: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   48 |             vr[p[j].second][r[p[j].second].back()] = i;
      |                                    ^~~~~~
tickets.cpp:49:20: error: 'class std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >' has no member named 'second'
   49 |             r[p[j].second].pop_back();
      |                    ^~~~~~