QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#693384 | #9422. Two-star Contest | Nana7# | WA | 67ms | 32804kb | C++14 | 1.5kb | 2024-10-31 16:03:35 | 2024-10-31 16:03:35 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define I inline
#define int long long
using namespace std;
const int N = 400010;
struct node {
vector<int> a;
int v,id;
int dn,up,fi,sm;
}a[N];
int n,m,k;
I bool cmp(node n1,node n2) {
return n1.v<n2.v;
}
I bool cmp2(node n1,node n2) {
return n1.id<n2.id;
}
I void out(node x) {
int rev=x.fi-x.sm;
//cout<<"!!"<<rev<<' '<<x.fi<<endl;
for(auto &t:x.a) {
if(t==-1) {
if(rev>=k) {
rev-=k;
cout<<k<<' ';
} else if(rev) {
cout<<rev<<' ';
rev=0;
} else {
cout<<0<<' ';
}
} else cout<<t<<' ';
} cout<<endl;
}
I void solve() {
cin>>n>>m>>k;
for(int i=1;i<=n;++i) a[i].a.clear(),a[i].up=a[i].dn=a[i].sm=a[i].fi=0;
for(int i=1;i<=n;++i) {
cin>>a[i].v;
a[i].id=i;
int sum=0,cnt=0;
for(int j=1;j<=m;++j) {
int x; cin>>x;
a[i].a.push_back(x);
if(x==-1) cnt++;
else sum+=x;
}
a[i].sm=sum;
a[i].dn=sum;
a[i].up=sum+cnt*k;
}
sort(a+1,a+1+n,cmp);
int mn=1,nv=0,can=1;
for(int i=1;i<=n;++i) {
if(a[i].v!=nv) {
for(int j=i-1;j>=1;--j) {
if(a[j].v==nv) mn=max(mn,a[j].fi+1);
else break;
}
nv=a[i].v;
}
if(a[i].up<max(mn,a[i].dn)) {
can=0;
break;
}
a[i].fi=max(mn,a[i].dn);
}
if(!can) {
cout<<"No"<<endl;
return ;
}
cout<<"Yes"<<endl;
sort(a+1,a+1+n,cmp2);
for(int i=1;i<=n;++i) {
out(a[i]);
}
}
signed main()
{
int T; cin>>T;
while(T--) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 31736kb
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 2 0 0 1 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 67ms
memory: 32804kb
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:
No Yes 0 849 0 0 33907 7926 9461 70117 96295 96295 56792 96295 75461 0 19527 0 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 975402536 248560376 0 0 ...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 1)