제출 #427030

#제출 시각아이디문제언어결과실행 시간메모리
427030zoooma13카니발 티켓 (IOI20_tickets)C++14
25 / 100
1126 ms111352 KiB
#include "bits/stdc++.h" #include "tickets.h" using namespace std; int n ,m ,k; vector <vector <int>> x; pair <int64_t ,vector <vector <int>>> construct(vector <int> pref){ assert(pref.size() == n && accumulate(pref.begin() ,pref.end() ,0) == n*k/2); vector <array <int ,3>> fh ,sh; for(int i = 0; i < n; i++){ for(int j = 0; j < pref[i]; j++) fh.push_back({x[i][j] ,i ,j}); for(int j = m-1; j >= m - (k-pref[i]); j--) sh.push_back({x[i][j] ,i ,j}); } sort(fh.begin() ,fh.end() ,[](auto&i ,auto&j){ return i[1] < j[1]; }); sort(sh.begin() ,sh.end() ,[](auto&i ,auto&j){ return i[1] < j[1]; }); int64_t tot = 0; vector<vector<int>> answer(n ,vector<int>(m ,-1)); vector<bitset<1501>> taken(n); for(auto&bs : taken) bs.set(); int round_number = 0; for(auto&c : fh){ tot -= c[0]; answer[c[1]][c[2]] = round_number; taken[c[1]][round_number] = false; round_number = (round_number+1 == k? 0 : round_number+1); } vector <int> pos(n ,-1); for(auto&c : sh){ tot += c[0]; pos[c[1]] = taken[c[1]]._Find_next(pos[c[1]]); answer[c[1]][c[2]] = pos[c[1]]; } return {tot ,answer}; } long long find_maximum(int _k, vector<vector<int>> _x) { x = _x; n = x.size(); m = x[0].size(); k = _k; vector <array <int ,2>> all; //{val ,color ,index} for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) all.push_back({x[i][j] ,i}); sort(all.begin() ,all.end()); int coll = 0; vector <int> pref(n ,0); for(auto&c : all){ if(pref[c[1]] < k) pref[c[1]]++ ,coll++; if(2*coll == n*k) break; } auto ans = construct(pref); allocate_tickets(ans.second); return ans.first; }

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

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from tickets.cpp:1:
tickets.cpp: In function 'std::pair<long int, std::vector<std::vector<int> > > construct(std::vector<int>)':
tickets.cpp:9:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |     assert(pref.size() == n && accumulate(pref.begin() ,pref.end() ,0) == n*k/2);
      |            ~~~~~~~~~~~~^~~~
#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...