제출 #569881

#제출 시각아이디문제언어결과실행 시간메모리
569881ngpin04카니발 티켓 (IOI20_tickets)C++17
11 / 100
7 ms12720 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); int sign[N][N]; int ans[N][N]; int cnt[N]; bool vis[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; int cntneg = 0, cntpos = 0; for (auto [i, j] : cell) { tot -= x[i][j]; cnt[i]++; sign[i][j] = -1; cntneg++; if (cntneg == (n >> 1) * k) break; } reverse(ALL(cell)); for (auto [i, j] : cell) { tot += x[i][j]; cnt[i]++; cntpos++; sign[i][j] = 1; if (cntpos == (n >> 1) * k) break; } for (int i = 0, cur = 0; i < n; i++) { for (int j = 0; j < k; j++) vis[j] = false; for (int j = 0, res = 0; j < m; j++) { if (sign[i][j] < 0) { ans[i][j] = cur % k; vis[cur % k] = true; cur++; } else { while (vis[res]) res++; ans[i][j] = res; } } } 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"
#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...