QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#662865 | #9422. Two-star Contest | Oo | WA | 47ms | 4108kb | C++20 | 1.7kb | 2024-10-21 11:26:35 | 2024-10-21 11:26:41 |
Judging History
answer
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define i128 __int128
#define db long double
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
//const int N=;
//const int M=;
//const int inf=(int)1e9;
//const ll INF=(ll)1e18;
int T, n;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
void solve() {
int n, m ,k;
cin >> n >> m >> k;
vector<vector<int>> a(n + 1, vector<int>(m + 1));
vector<pair<int, int>> s(n + 1);
for(int i = 1; i <= n; i++){
cin >> s[i].first;
s[i].second = i;
for(int j = 1; j <= m; j++) cin >> a[i][j];
}
sort(s.begin() + 1, s.end());
int last = -1, same = 0;
for(int p = 1; p <= n; p++) {
int i = s[p].second;
if(p > 1 && s[p].second != s[p - 1].second) {
assert(same > last);
last = same;
same = 0;
}
int sum = 0;
for(int j = 1; j <= m; j++) {
if(a[i][j] == -1) continue;
sum += a[i][j];
}
int need = last + 1;
for(int j= 1; j <= m; j++) {
if(a[i][j] == -1){
a[i][j] = min(k, max(0LL, need - sum));
sum += a[i][j];
}
}
if(sum < need) {
cout << "No\n";
return;
}
same = max(same, sum);
// last = {max(sum, lastsum), s[p].first};
}
cout << "Yes\n";
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) cout << a[i][j] << ' ';
cout << '\n';
}
}
signed main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
int T;
cin >> T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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 3 0 5 0 5 3 4 0 4 No Yes 1 2 3 4 5 6 No Yes 1 0 0 0 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 47ms
memory: 4108kb
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 0 849 0 0 33907 7926 9461 70117 96295 96295 56792 96295 75462 0 19527 0 12828 30553 40825 67577 91517 77952 55631 63781 29385 96295 96295 96295 750 96295 25350 0 Yes 0 0 66436933 0 45419040 55642613 14090348 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 9...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 11)