QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#857766 | #64. Naan | makrav | 0 | 12ms | 10496kb | C++20 | 2.3kb | 2025-01-16 01:58:56 | 2025-01-16 01:58:56 |
Judging History
answer
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using ll = long long;
using ld = long double;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second
#define int ll
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
void shuf(vector<T>& a) {
for (int i = 1; i < sz(a); i++) swap(a[i], a[rnd() % (i + 1)]);
}
void solve() {
int n, l; cin >> n >> l;
vector<vector<int>> a(n, vector<int>(l));
for (int i = 0; i < n; i++) {
for (int j = 0; j < l; j++) cin >> a[i][j];
}
vector<ll> sm(n);
for (int i = 0; i < n; i++) sm[i] = accumulate(all(a[i]), 0ll);
vector<vector<pair<int, int>>> xd(n, vector<pair<int, int>>(n));
for (int i = 0; i < n; i++) {
ll smm = 0;
int cur = 0;
for (int curnum = 1; curnum <= n; curnum++) {
while (cur < l && (smm + a[i][cur]) * n <= sm[i] * curnum) {
smm += a[i][cur++];
}
if (smm * n == sm[i] * curnum) {
xd[i][curnum - 1] = {cur, 1};
} else {
int need_dop = sm[i] * curnum - smm * n;
int znam = n * a[i][cur];
xd[i][curnum - 1] = {need_dop + znam * cur, znam};
}
}
}
vector<pair<int, int>> ans(n);
vector<int> used(n, 0), ans_p(n);
auto compare = [&](pair<int, int> fr1, pair<int, int> fr2) {
return (ld)fr1.first / (ld)fr1.second < (ld)fr2.first / (ld)fr2.second;
};
for (int i = 0; i < n; i++) {
int bi = -1;
for (int j = 0; j < n; j++) {
if (!used[j] && (bi == -1 || compare(xd[j][i], xd[bi][i]))) bi = j;
}
ans[i] = xd[bi][i];
ans_p[i] = bi + 1;
used[bi] = 1;
}
for (int i = 0; i < n; i++) cout << ans[i].first << ' ' << ans[i].second << '\n';
for (int u : ans_p) cout << u << ' ';
cout << '\n';
}
signed main() {
int tt = 1;
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
cin >> tt;
#else
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#endif
while (tt--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3840kb
input:
2 1516 42058 25892 51128 40494 78380 30332 47660 58339 90812 50469 28184 75581 61837 25051 90975 98279 81022 90217 31015 72984 89884 68399 47215 10071 43418 61089 91302 96661 47701 86531 26050 80503 54870 1405 71971 39883 82485 66816 115 49358 86761 24392 32521 87048 19107 56752 23862 96755 80318 44...
output:
118534088 158076 1516 1 2 1
result:
wrong answer Integer parameter [name=P_i] equals to 1516, violates the range [1, 2]
Subtask #2:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
2 1168 4 10 7 6 10 3 9 5 7 10 9 7 9 1 5 9 8 5 3 4 5 2 10 7 6 2 4 5 2 4 4 8 10 1 2 9 1 3 6 6 3 8 8 1 8 4 5 6 7 9 2 2 3 2 8 9 4 7 8 9 8 6 8 4 6 3 5 4 5 1 5 5 10 8 2 4 8 1 9 1 7 6 10 4 4 2 3 4 6 3 2 9 1 10 3 8 8 10 8 1 8 10 8 6 1 1 3 8 2 6 8 6 8 9 8 1 7 6 9 3 2 1 5 2 8 6 4 4 1 2 9 2 6 6 8 2 4 2 2 4 6 4...
output:
5696 10 1168 1 2 1
result:
wrong answer Integer parameter [name=P_i] equals to 1168, violates the range [1, 2]
Subtask #3:
score: 0
Wrong Answer
Test #42:
score: 0
Wrong Answer
time: 12ms
memory: 10496kb
input:
563 467 8049 85539 27182 28071 94216 41847 50021 12220 27028 36160 7314 23133 44548 80654 65291 17329 61691 98590 68874 59735 6789 7383 17300 46373 35858 95819 15891 55598 25928 20662 99160 79046 1004 1901 33290 20640 86369 3246 36921 56090 11582 48092 48473 32198 80924 42208 80056 24593 43827 68820...
output:
22348400 56010618 44837792 56053406 68854267 55673944 93215158 53267119 99917765 44916703 132106351 47920308 183546783 56230188 218158172 54890811 185721461 40219031 235965024 44658849 275185257 47523393 260200404 39855333 160597838 22559973 370281996 48089208 449162366 53959609 387220215 42937195 4...
result:
wrong answer