QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#603833 | #9422. Two-star Contest | snow | AC ✓ | 56ms | 12272kb | C++23 | 5.4kb | 2024-10-01 19:56:07 | 2024-10-01 19:56:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct node
{
ll s;
ll sum;
ll index;
ll cnt;
};
bool cmp(struct node a, struct node b)
{
if (a.s == b.s)
return a.sum < b.sum;
else
return a.s < b.s;
}
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t;
cin >> t;
while (t--)
{
ll f = 1;
ll n, m, k;
cin >> n >> m >> k;
struct node a[n + 3];
ll g[n + 3][m + 3];
for (ll i = 1; i <= n; i++)
{
cin >> a[i].s;
ll sum = 0;
ll cnt = 0;
for (ll j = 1; j <= m; j++)
{
cin >> g[i][j];
if (g[i][j] == -1)
cnt++;
else
sum += g[i][j];
}
a[i].sum = sum;
a[i].index = i;
a[i].cnt = cnt;
}
sort(a + 1, a + n + 1, cmp);
ll maxx = a[1].sum;
ll pre = -1;
for (ll i = 1; i <= m; i++)
{
if (g[a[1].index][i] == -1)
g[a[1].index][i] = 0;
}
for (ll i = 2; i <= n; i++)
{
if (a[i].s == a[i - 1].s)
{
maxx = max(maxx, a[i].sum);
if (a[i].sum > pre)
{
for (ll j = 1; j <= m; j++)
{
if (g[a[i].index][j] == -1)
g[a[i].index][j] = 0;
}
}
else
{
ll need = pre - a[i].sum + 1;
if (a[i].cnt * k < need)
{
f = 0;
break;
}
else
{
ll flag = 1;
for (ll j = 1; j <= m; j++)
{
if (g[a[i].index][j] == -1)
{
if (!flag)
{
g[a[i].index][j] = 0;
}
else
{
if (need >= k)
{
need -= k;
g[a[i].index][j] = k;
}
else
{
g[a[i].index][j] = need;
need = 0;
}
if (!need)
flag = 0;
}
}
}
}
}
for (ll j = 1; j <= m; j++)
{
if (g[a[i].index][j] == -1)
g[a[i].index][j] = 0;
}
}
else
{
pre=maxx;
if (a[i].sum > maxx)
{
maxx = a[i].sum;
for (ll j = 1; j <= m; j++)
{
if (g[a[i].index][j] == -1)
g[a[i].index][j] = 0;
}
}
else
{
ll need = maxx - a[i].sum + 1;
if (a[i].cnt * k < need)
{
f = 0;
break;
}
else
{
ll flag = 1;
for (ll j = 1; j <= m; j++)
{
if (g[a[i].index][j] == -1)
{
if (!flag)
{
g[a[i].index][j] = 0;
}
else
{
if (need >= k)
{
need -= k;
g[a[i].index][j] = k;
}
else
{
g[a[i].index][j] = need;
need = 0;
}
if (!need)
flag = 0;
}
}
}
maxx = maxx + 1;
}
}
}
}
if (!f)
cout << "No\n";
else
{
cout << "Yes\n";
for (ll i = 1; i <= n; i++)
{
for (ll j = 1; j <= m; j++)
cout << g[i][j] << ' ';
cout << '\n';
}
}
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
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: 23ms
memory: 4544kb
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: 22ms
memory: 5472kb
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: 19ms
memory: 4928kb
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: 0
Accepted
time: 50ms
memory: 12256kb
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:
Yes 1000000000 1000000000 1000000000 890401574 1000000000 944106300 988594490 957701029 990531523 995024780 931575689 973269210 1000000000 963284307 970527902 956589076 1000000000 1000000000 1000000000 890401236 926430988 986897392 988002785 989069881 950386440 995445423 999667024 944902387 9...
result:
ok ok 1 cases (1 test case)
Test #6:
score: 0
Accepted
time: 56ms
memory: 12268kb
input:
1 100000 4 1000000000 782 -1 -1 -1 947277126 7463 911868853 663066601 304654319 956097480 7026 543996878 -1 -1 -1 9977 -1 -1 -1 -1 4163 -1 -1 974553368 997656454 2087 -1 965058038 846071376 284559395 2860 939952548 -1 855300200 833962513 4460 -1 -1 -1 -1 9015 937803884 -1 -1 226210831 1049 992111579...
output:
Yes 1000000000 888343142 0 947277126 911868853 663066601 304654319 956097480 543996878 1000000000 1000000000 291685881 1000000000 1000000000 835712084 0 863444267 0 974553368 997656454 739944579 965058038 846071376 284559395 939952548 206425807 855300200 833962513 1000000000 1000000000 835657...
result:
ok ok 1 cases (1 test case)
Test #7:
score: 0
Accepted
time: 55ms
memory: 12272kb
input:
1 100000 4 1000000000 12343 -1 -1 163618742 -1 23008 -1 -1 80109196 -1 25158 83256587 205974683 966757544 241529041 15857 405493766 -1 471928169 -1 23206 47432606 35185749 442825875 972071673 3162 -1 531880118 -1 679347758 11309 4212902 510812429 244398710 738079965 9219 -1 377058342 168784276 46444...
output:
Yes 1000000000 333886298 163618742 0 1000000000 417406509 80109196 0 83256587 205974683 966757544 241529041 405493766 620086619 471928169 0 47432606 35185749 442825875 972071673 286267983 531880118 0 679347758 4212902 510812429 244398710 738079965 905215226 377058342 168784276 46444072 44737...
result:
ok ok 1 cases (1 test case)
Test #8:
score: 0
Accepted
time: 6ms
memory: 4540kb
input:
1 330 331 1000000000 17 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 -1 0 0 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 0 -1 -1 0 -1 -1 0 -...
output:
Yes 1000000000 1000000000 1000000000 1000000000 0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000000...
result:
ok ok 1 cases (1 test case)
Test #9:
score: 0
Accepted
time: 11ms
memory: 4548kb
input:
1 330 331 1000000000 17 946429399 987445451 11812057 978102123 215602643 18892727 79870522 412571676 1000000000 353424709 430456330 1000000000 405985858 944004524 24203548 851415355 97745912 13615759 362558277 173680958 689298756 221029170 725082203 81224466 16747894 1000000000 1000000000 826943001 ...
output:
Yes 946429399 987445451 11812057 978102123 215602643 18892727 79870522 412571676 1000000000 353424709 430456330 1000000000 405985858 944004524 24203548 851415355 97745912 13615759 362558277 173680958 689298756 221029170 725082203 81224466 16747894 1000000000 1000000000 826943001 5521409 281072909 68...
result:
ok ok 1 cases (1 test case)
Test #10:
score: 0
Accepted
time: 12ms
memory: 4472kb
input:
1 330 331 1000000000 93 1000000000 957480495 1000000000 954239930 999999387 817203596 128888131 1000000000 395767152 893779444 1000000000 1000000000 999999280 1000000000 512807103 1000000000 1000000000 815708342 624663854 3711760 402990567 485458597 875421915 999749540 192329441 302790028 950609494 ...
output:
Yes 1000000000 957480495 1000000000 954239930 999999387 817203596 128888131 1000000000 395767152 893779444 1000000000 1000000000 999999280 1000000000 512807103 1000000000 1000000000 815708342 624663854 3711760 402990567 485458597 875421915 999749540 192329441 302790028 950609494 294653401 102935655 ...
result:
ok ok 1 cases (1 test case)
Test #11:
score: 0
Accepted
time: 41ms
memory: 7792kb
input:
1 10 40000 1000000000 1 1000000000 -1 -1 7508585 1000000000 1000000000 1000000000 604390543 -1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 901948669 1000000000 794014234 1000000000 -1 -1 1000000000 1000000000 857845945 817246643 1000000000 -1 1000000000 1000000000 10...
output:
Yes 1000000000 0 0 7508585 1000000000 1000000000 1000000000 604390543 0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 901948669 1000000000 794014234 1000000000 0 0 1000000000 1000000000 857845945 817246643 1000000000 0 1000000000 1000000000 1000000000 1000000000 100000...
result:
ok ok 1 cases (1 test case)
Test #12:
score: 0
Accepted
time: 39ms
memory: 7708kb
input:
1 10 40000 1000000000 6 1000000000 1000000000 906478621 13209691 922818115 77559562 438363123 591871569 848893630 102398661 534268791 178087467 686311759 601080260 123177170 514948894 494568232 115297150 440603707 273127320 1000000000 662873117 15207013 148894259 947428836 393166189 952301343 508048...
output:
Yes 1000000000 1000000000 906478621 13209691 922818115 77559562 438363123 591871569 848893630 102398661 534268791 178087467 686311759 601080260 123177170 514948894 494568232 115297150 440603707 273127320 1000000000 662873117 15207013 148894259 947428836 393166189 952301343 50804815 131098501 8667868...
result:
ok ok 1 cases (1 test case)
Test #13:
score: 0
Accepted
time: 32ms
memory: 7728kb
input:
1 10 40000 1000000000 4 0 372110345 49491905 239373904 0 0 698435066 0 989414051 0 0 0 800769773 0 0 24299236 0 939825010 890065504 48152345 0 467166947 750051791 821016755 0 120129636 0 263963291 0 0 312914024 149064941 870472040 0 0 0 0 594433737 135980261 0 303039534 250195779 259062916 753648254...
output:
Yes 0 372110345 49491905 239373904 0 0 698435066 0 989414051 0 0 0 800769773 0 0 24299236 0 939825010 890065504 48152345 0 467166947 750051791 821016755 0 120129636 0 263963291 0 0 312914024 149064941 870472040 0 0 0 0 594433737 135980261 0 303039534 250195779 259062916 753648254 0 45469080 14951577...
result:
ok ok 1 cases (1 test case)
Extra Test:
score: 0
Extra Test Passed