QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692541 | #9422. Two-star Contest | Z-wzy | WA | 31ms | 4384kb | C++20 | 1.6kb | 2024-10-31 14:40:49 | 2024-10-31 14:41:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
const int mod = 1e9 + 7, inf = 1e17;
struct AC{
int sp, id;
vector<int> g;
};
void run(){
int n, m, k;
cin >> n >> m >> k;
vector<AC> g(n);
for(int i=0;i<n;i++){
cin >> g[i].sp;
for(int j=0;j<m;j++){
int x;
cin >> x;
g[i].g.push_back(x);
}
g[i].id = i;
}
sort(g.begin(), g.end(), [&](AC x, AC y){
return x.sp > y.sp;
});
int ans = 0;
for(auto &i: g[0].g){
if(i == -1) i = k;
ans += i;
}
for(int i=1;i<n;i++){
int sum = 0;
for(auto &j: g[i].g){
if(j != -1){
sum += j;
}
}
if(sum >= ans && g[i].sp < g[i - 1].sp){
cout << "No\n";
return;
}
if(sum > ans){
cout << "No\n";
return;
}
for(auto &j: g[i].g){
if(j == -1){
j = min(ans - sum - (g[i].sp < g[i - 1].sp), k);
sum += j;
}
}
ans = sum;
}
sort(g.begin(), g.end(), [&](AC x, AC y){
return x.id < y.id;
});
cout << "Yes\n";
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout << g[i].g[j] << " \n"[j == m - 1];
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
while(T --) run(); return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 31ms
memory: 4384kb
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 No Yes 72716304 72716304 66436933 72716304 45419040 55642613 72716304 62712753 72716304 21765515 56544945 12385026 Yes 975402536 975402536 975402536 975402536 975402536 975402536 67482408 0 0 975402536 975402536 975402536 975402536 211610436 944794448 67558026 0 0 788675016 424172233...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 2)