이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
for (int i = 0, cur = 0; i < (int) neg.size(); i++) {
auto [u, v] = neg[i];
ans[u][v] = cur;
cnt[cur]++;
if (cnt[cur] == (n >> 1))
cur++;
}
for (int i = 0, cur = 0; i < (int) pos.size(); i++) {
auto [u, v] = pos[i];
ans[u][v] = cur;
cnt[cur]++;
if (cnt[cur] == (n >> 1))
cur++;
}
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |