제출 #569877

#제출 시각아이디문제언어결과실행 시간메모리
569877ngpin04카니발 티켓 (IOI20_tickets)C++17
11 / 100
4 ms6740 KiB
#include "tickets.h" #include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define TASK "" #define bit(x) (1LL << (x)) #define getbit(x, i) (((x) >> (i)) & 1) #define ALL(x) (x).begin(), (x).end() using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return l + rd() % (r - l + 1); } const int N = 1505; const int oo = 1e9; const long long ooo = 1e18; const int mod = 1e9 + 7; // 998244353; const long double pi = acos(-1); vector <pair <int, int>> pos, neg; int ans[N][N]; int cnt[N]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); if (k != m) exit(0); vector <pair <int, int>> cell; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { cell.push_back({i, j}); ans[i][j] = -1; } sort(ALL(cell), [&](pair <int, int> a, pair <int, int> b) { return x[a.fi][a.se] < x[b.fi][b.se]; }); long long tot = 0; for (auto [i, j] : cell) { neg.push_back({i, j}); tot -= x[i][j]; cnt[i]++; if (neg.size() == (n >> 1) * k) break; } reverse(ALL(cell)); for (auto [i, j] : cell) { pos.push_back({i, j}); tot += x[i][j]; cnt[i]++; if (pos.size() == (n >> 1) * k) break; } for (int i = 0; i < k; i++) cnt[i] = 0; sort(ALL(neg)); sort(ALL(pos)); for (int i = 0; i < (int) neg.size(); i++) { auto [u, v] = neg[i]; ans[u][v] = i % k; } for (int i = 0; i < (int) pos.size(); i++) { auto [u, v] = pos[i]; ans[u][v] = i % k; } vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row; for (int j = 0; j < m; j++) row.push_back(ans[i][j]); answer.push_back(row); } allocate_tickets(answer); return tot; } //#include "grader.cpp"

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:57:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |   if (neg.size() == (n >> 1) * k)
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~
tickets.cpp:66:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |   if (pos.size() == (n >> 1) * k)
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~
#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...