QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#669130 | #9422. Two-star Contest | Pepinot | WA | 26ms | 4444kb | C++20 | 2.5kb | 2024-10-23 17:23:12 | 2024-10-23 17:23:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
struct per {
int type;
vector<int> vv;
int sum=0;
int cnt=0;
int idx;
int end;
// bool operator<(const per other) const {
// if(type==other.type) return sum<other.sum;
// return type<other.type;
// }
};
bool cmp1(per a,per b) {
if(a.type==b.type) return a.sum<b.sum;
return a.type<b.type;
}
bool cmp2(per a,per b) {
return a.idx<b.idx;
}
void solve() {
int n,m,k; cin>>n>>m>>k;
vector<per> v(n);
for(int i=0; i<n; i++) {
cin>>v[i].type;
v[i].idx=i;
for(int j=0; j<m; j++) {
int x; cin>>x;
if(x!=-1) v[i].sum+=x;
else v[i].cnt++,v[i].end=j;
v[i].vv.push_back(x);
}
}
sort(v.begin(),v.end(),cmp1);
for(int i=0; i<v[0].vv.size(); i++)
if(v[0].vv[i]==-1) v[0].vv[i]=0;
for(int i=1; i<n; i++) {
if(v[i-1].type<v[i].type) {
if(v[i-1].sum<v[i].sum) {
for(int j=0; j<v[i].vv.size(); j++)
if(v[i].vv[j]==-1) v[i].vv[j]=0;
}
else {
int cha=v[i-1].sum-v[i].sum;
if(v[i].cnt*k<=cha) {
cout<<"No\n";
return;
}
for(int j=0; j<v[i].end; j++) {
if(v[i].vv[j]==-1) {
if(cha>=k) {
v[i].vv[j]=k;
cha-=k;
}
else if(cha>0) {
v[i].vv[j]=cha;
cha=0;
}
else v[i].vv[j]=0;
}
}
v[i].vv[v[i].end]=cha+1;
v[i].sum=v[i-1].sum+1;
}
}
}
sort(v.begin(),v.end(),cmp2);
cout<<"Yes\n";
for(int i=0; i<n; i++) {
for(auto j:v[i].vv) {
if(j==-1) cout<<"0 ";
else cout<<j<<" ";
}
cout<<endl;
}
}
signed main()
{
ios::sync_with_stdio(false),cin.tie(nullptr);
int t; cin>>t;
while(t--)
solve();
}
/*
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
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
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 3 1 4 No Yes 1 2 3 4 5 6 No Yes 0 0 1 0 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 4444kb
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 75460 0 19527 1 12828 30553 40825 67577 91517 77952 55631 63781 29385 0 0 0 750 0 0 0 Yes 0 0 66436933 0 45419040 55642613 0 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 975402536 975402536 97540253...
result:
wrong answer Participant cannot satisfy the constraint. (test case 4)