QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#716629 | #9422. Two-star Contest | crazymoon | WA | 26ms | 4172kb | C++20 | 1.5kb | 2024-11-06 15:41:50 | 2024-11-06 15:41:52 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const double eps = 1e-8;
void solve() {
int n, m, k;
cin >> n >> m >> k;
vector<pair<int, int>> a(n + 1);
vector<vector<int>> g(n + 1 , vector<int>(m + 1));
for (int i = 1; i <= n; ++i) {
cin >> a[i].first;
a[i].second = i;
for (int j = 1; j <= m; ++j) cin >> g[i][j];
}
sort(a.begin() + 1, a.end(), greater<pair<int, int>>());
map<int, int> minx;
minx[0] = 1e16;
for (int i = 1; i <= n; ++i) {
int ti = a[i].second;
int sum = 0, lst = minx[a[i - 1].first];
for (int j = 1; j <= m; ++j) {
if(g[ti][j] != -1) sum += g[ti][j];
}
if(sum >= lst) {
cout << "No\n";
return ;
}
for (int j = 1; j <= m; ++j) {
if(g[ti][j] == -1) {
int tmp = min(k, lst - 1 - sum);
g[ti][j] = tmp;
sum += tmp;
}
}
if(!minx.count(a[i].first)) minx[a[i].first] = sum;
else minx[a[i].first] = min(minx[a[i].first], sum);
}
cout << "Yes\n";
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cout << g[i][j] << " \n"[j == m];
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1; cin >> t;
while(t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
5 3 4 5 5 1 3 -1 -1 2 -1 5 -1 5 3 3 -1 -1 4 2 3 10 10000 5 0 -1 1 10 10 10 2 3 10 10 1 2 3 100 4 5 6 2 3 10 100 1 2 3 10 4 5 6 2 3 10000 100 -1 -1 -1 1 -1 -1 -1
output:
Yes 1 3 5 5 2 5 0 5 3 5 1 4 No Yes 1 2 3 4 5 6 No Yes 10000 10000 10000 10000 10000 9999
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 4172kb
input:
1013 3 2 1 1 -1 -1 2 0 1 3 -1 -1 4 8 96295 302790137 -1 849 -1 -1 33907 7926 9461 70117 695984050 -1 -1 56792 -1 -1 -1 19527 -1 302790137 12828 30553 40825 67577 91517 77952 55631 63781 302790137 29385 -1 -1 -1 750 -1 -1 -1 2 6 72716304 892657961 -1 -1 66436933 -1 45419040 55642613 892657961 -1 6271...
output:
Yes 0 0 0 1 1 1 Yes 96295 849 96295 96295 33907 7926 9461 70117 96295 96295 56792 96295 96295 96295 19527 96295 12828 30553 40825 67577 91517 77952 55631 63781 29385 96295 96295 96295 750 96295 96295 96295 Yes 72716304 58625956 66436933 0 45419040 55642613 72716304 62712753 72716304 21765515 5654494...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 11)