QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628830 | #9422. Two-star Contest | Zhou_JK | WA | 27ms | 10496kb | C++23 | 1.6kb | 2024-10-10 22:37:26 | 2024-10-10 22:37:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=400005;
const long long INF=1e18;
int n,m,q;
int s[N];
int pool[N];
int id[N];
long long sum[N];
void solve()
{
cin>>n>>m>>q;
int (&p)[n+1][m+1]=*reinterpret_cast<int(*)[n+1][m+1]>(&pool);
for(int i=1;i<=n;i++)
{
cin>>s[i];
for(int j=1;j<=m;j++)
cin>>p[i][j];
}
for(int i=1;i<=n;i++)
id[i]=i;
sort(id+1,id+n+1,[=](const int &x,const int &y){return s[x]<s[y];});
long long mx=-1;
for(int i=1,j=1;i<=n;i=j)
{
while(j<=n&&s[id[i]]==s[id[j]]) j++;
for(int k=i;k<j;k++)
{
sum[id[k]]=0;
for(int l=1;l<=m;l++)
if(p[id[k]][l]!=-1) sum[id[k]]+=p[id[k]][l];
long long ret=max(mx-sum[id[k]]+1,0ll);
for(int l=1;l<=m;l++)
if(p[id[k]][l]==-1)
{
long long d=min((long long)q,ret);
p[id[k]][l]=d;
ret-=d;
sum[id[k]]+=d;
}
if(sum[id[k]]<=mx)
{
cout<<"No\n";
return;
}
}
for(int k=i;k<j;k++)
mx=max(mx,sum[id[k]]);
}
cout<<"Yes\n";
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
cout<<p[i][j]<<" ";
cout<<"\n";
}
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int T;
cin>>T;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7688kb
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: 0
Accepted
time: 27ms
memory: 9740kb
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 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 97540253...
result:
ok ok 1013 cases (1013 test cases)
Test #3:
score: 0
Accepted
time: 18ms
memory: 7920kb
input:
1111 7 4 4875072 988895277 -1 -1 -1 -1 254020497 -1 -1 4323135 3396854 988895277 4185157 341145 3608618 -1 16233727 -1 -1 -1 -1 254020497 11056 -1 1088108 1709022 16233727 -1 -1 1334067 1265037 16233727 -1 -1 -1 -1 4 2 86044173 929509241 43292045 66538315 768929945 27336311 -1 20849622 -1 11458851 2...
output:
Yes 4875072 2844918 0 0 0 0 4323135 3396854 4185157 341145 3608618 0 0 0 0 0 11056 0 1088108 1709022 0 0 1334067 1265037 0 0 0 0 Yes 43292045 66538315 27336311 0 0 11458851 11458852 0 No No Yes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1405609 0 0 Yes 0 0 0 0 0 0 0 0 0 992 992 200 0 0 0 658 0 ...
result:
ok ok 1111 cases (1111 test cases)
Test #4:
score: 0
Accepted
time: 23ms
memory: 7684kb
input:
1111 4 1 4321145 490702144 458299 284660056 -1 138628383 -1 598813561 -1 2 8 3 668536478 -1 2 -1 -1 3 -1 2 -1 753736433 -1 -1 2 -1 -1 -1 -1 -1 5 7 2886596 818960470 490915 2479956 -1 269393 1703673 274483 1984486 954760589 -1 -1 -1 -1 -1 1242359 660249 956153901 -1 2529502 -1 -1 -1 -1 2740104 954760...
output:
Yes 458299 1 0 458300 Yes 0 2 0 0 3 0 2 0 3 3 2 0 0 0 0 0 Yes 490915 2479956 0 269393 1703673 274483 1984486 2886596 2413704 0 0 0 1242359 660249 1933303 2529502 0 0 0 0 2740104 2021634 2886596 1911789 0 0 0 382889 2886596 1829485 591244 1895582 0 0 0 No Yes 20 0 0 25 29 36 0 0 0 0 0 11 ...
result:
ok ok 1111 cases (1111 test cases)
Test #5:
score: -100
Wrong Answer
time: 25ms
memory: 10496kb
input:
1 100000 4 1000000000 60 -1 -1 -1 -1 86 -1 944106300 988594490 -1 20 990531523 995024780 -1 973269210 28 -1 -1 970527902 956589076 23 -1 -1 -1 -1 10 -1 986897392 988002785 989069881 25 -1 995445423 999667024 944902387 89 925354637 997675637 996571399 -1 72 -1 -1 -1 998653307 57 -1 -1 -1 953746873 1 ...
output:
No
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 1)