Submission #405186

#TimeUsernameProblemLanguageResultExecution timeMemory
405186ly20Carnival Tickets (IOI20_tickets)C++17
14 / 100
955 ms81340 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1512; int tb[MAXN][MAXN]; vector <int> v0[MAXN], v1[MAXN]; int id0[MAXN], id1[MAXN]; int n, m; int resp[MAXN][MAXN]; long long find_maximum(int k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); long long mx = 0; vector <vector <int> > answer; //answer.push_back(temp); set <pair <int, int> > s0, s1; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(x[i][j] == 0) v0[i].push_back(j); else v1[i].push_back(j); resp[i][j] = -1; } } for(int i = 0; i < n; i++) { s0.insert(make_pair(v0[i].size(), i)); s1.insert(make_pair(v1[i].size(), -i)); } long long rs = 0; for(int i = 0; i < k; i++) { int qt0, qt1; int ot = n / 2; int qta, qtb; if(s0.size() >= ot && s1.size() >= ot) { qta = ot; qtb = ot; } else if(s0.size() < ot) { qta = s0.size(); qtb = n - qta; } else { qtb = s1.size(); qta = n - qtb; } rs += min(qta, qtb); vector <pair <int, int> > ida; for(int j = 0; j < qta; j++) { pair <int, int> a = (*(--s0.end())); int ia = a.second; s0.erase(--s0.end()); a.first--; resp[ia][v0[ia][id0[ia]]] = i; id0[ia]++; if(a.first != 0) ida.push_back(a); } for(int j = 0; j < ida.size(); j++) s0.insert(ida[j]); vector <pair <int, int> > idb; for(int j = 0; j < qtb; j++) { pair <int, int> b = (*(--s1.end())); int ib = -b.second; s1.erase(--s1.end()); b.first--; resp[ib][v1[ib][id1[ib]]] = i; id1[ib]++; if(b.first != 0) idb.push_back(b); } for(int j = 0; j < idb.size(); j++) s1.insert(idb[j]); } for(int i = 0; i < n; i++) { vector <int> row; for(int j = 0; j < m; j++) { row.push_back(resp[i][j]); } answer.push_back(row); } allocate_tickets(answer); return rs; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:34:22: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if(s0.size() >= ot && s1.size() >= ot) {
      |            ~~~~~~~~~~^~~~~
tickets.cpp:34:41: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if(s0.size() >= ot && s1.size() >= ot) {
      |                               ~~~~~~~~~~^~~~~
tickets.cpp:37:27: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |         else if(s0.size() < ot) {
      |                 ~~~~~~~~~~^~~~
tickets.cpp:56:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for(int j = 0; j < ida.size(); j++) s0.insert(ida[j]);
      |                        ~~^~~~~~~~~~~~
tickets.cpp:67:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for(int j = 0; j < idb.size(); j++) s1.insert(idb[j]);
      |                        ~~^~~~~~~~~~~~
tickets.cpp:31:13: warning: unused variable 'qt0' [-Wunused-variable]
   31 |         int qt0, qt1;
      |             ^~~
tickets.cpp:31:18: warning: unused variable 'qt1' [-Wunused-variable]
   31 |         int qt0, qt1;
      |                  ^~~
tickets.cpp:14:12: warning: unused variable 'mx' [-Wunused-variable]
   14 |  long long mx = 0;
      |            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...