QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#719418 | #9422. Two-star Contest | Layn# | WA | 38ms | 34264kb | C++14 | 1.9kb | 2024-11-07 00:51:31 | 2024-11-07 00:51:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
int T,n,m,k;
long long mx[N];
vector<int>b[N];
struct Layn {
int s,cnt,id;
long long sum;
vector<int>p;
}a[N];
bool cmp1(Layn x,Layn y){return x.s<y.s;}
bool cmp2(Layn x,Layn y){return x.id<y.id;}
int main() {
scanf("%d",&T);
while(T--) {
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)a[i].p.clear(),a[i].p.push_back(0),b[i].clear();
for(int i=1;i<=n;i++) {
scanf("%d",&a[i].s),a[i].cnt=0,a[i].sum=0;
for(int j=1,x;j<=m;j++) {
scanf("%d",&x),a[i].p.push_back(x);
if(x<0)a[i].cnt++;
else a[i].sum+=x;
a[i].id=i;
}
}
sort(a+1,a+n+1,cmp1);
int siz=0;
for(int i=1;i<=n;i++) {
if(a[i].s>a[i-1].s)++siz;
b[siz].push_back(i);
}bool flag=0;
for(int i=1;i<=siz;i++) {
mx[i]=0;
for(int j:b[i]) {
//printf("%d %d %d %d----\n",a[j].s,a[j].cnt,a[j].sum,mx[i-1]);
if(a[j].sum+1ll*k*a[j].cnt<=mx[i-1]){flag=1;break;}
for(int l=1;l<=m;l++)if(a[j].p[l]<0) {
if(a[j].sum<=mx[i-1])a[j].p[l]=min(mx[i-1]+1-a[j].sum,1ll*k);
else a[j].p[l]=0;
a[j].sum+=a[j].p[l];
}
mx[i]=max(mx[i],a[j].sum);
}
if(flag)break;
}
sort(a+1,a+n+1,cmp2);
if(flag)puts("No");
else {
puts("Yes");
for(int i=1;i<=n;i++,puts(""))for(int j=1;j<=m;j++)printf("%d ",a[i].p[j]);
}
}
}
// 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: 4ms
memory: 34220kb
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: 38ms
memory: 34264kb
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)