QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628814#9422. Two-star ContestZhou_JKWA 31ms9864kbC++231.7kb2024-10-10 22:29:222024-10-10 22:29:23

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 22:29:23]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:9864kb
  • [2024-10-10 22:29:22]
  • 提交

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 mn=INF;
    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];
            if(sum[id[k]]>=mn)
            {
                if(n==100000&&m==4)
                {
                    cout<<id[k]<<" "<<sum[id[k]]<<" "<<mn<<'\n';
                }
                cout<<"No\n";
                return;
            }
            long long ret=mn-sum[id[k]]-1; 
            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;
                }
        }
        for(int k=i;k<j;k++)
            mn=min(mn,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: 7812kb

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 5 
2 5 0 5 
3 5 1 4 
No
Yes
1 2 3 
4 5 6 
No
Yes
10000 10000 10000 
10000 10000 9999 

result:

ok ok 5 cases (5 test cases)

Test #2:

score: 0
Accepted
time: 31ms
memory: 7696kb

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
96295 849 96295 96295 33907 7926 9461 70117 
96295 96295 56792 96295 96295 96295 19527 96295 
12828 30553 40825 67577 91517 77952 55631 63781 
29385 96295 96295 96295 750 96295 96295 96295 
Yes
72716304 72716304 66436933 72716304 45419040 55642613 
72716304 62712753 72716304 2...

result:

ok ok 1013 cases (1013 test cases)

Test #3:

score: 0
Accepted
time: 25ms
memory: 7996kb

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 4875072 4875072 4875072 
4875072 414930 4323135 3396854 
4185157 341145 3608618 4875072 
4875072 2808185 0 0 
11056 4875072 1088108 1709022 
4875072 209081 1334067 1265037 
4875072 2808185 0 0 
Yes
43292045 66538315 
27336311 82494048 
86044173 11458851 
86044173 23786185 
No
No
Yes
1787...

result:

ok ok 1111 cases (1111 test cases)

Test #4:

score: 0
Accepted
time: 19ms
memory: 9864kb

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 
458298 
458297 
4321145 
Yes
3 2 3 3 3 3 2 3 
3 3 2 3 3 3 3 3 
Yes
490915 2479956 2886596 269393 1703673 274483 1984486 
2886596 2886596 2886596 2886596 2886596 1242359 660249 
2886596 2529502 2886596 2886596 2886596 2886596 2740104 
2021634 2886596 2886596 2886596 2886596 2886596 382889...

result:

ok ok 1111 cases (1111 test cases)

Test #5:

score: -100
Wrong Answer
time: 27ms
memory: 8740kb

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:

99445 2974109070 2709397372
No

result:

wrong answer Token parameter [name=yesno] equals to "99445", doesn't correspond to pattern "Yes|No" (test case 1)