QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177416 | #7118. Closing Time | triple321# | 21 | 94ms | 25776kb | C++20 | 2.6kb | 2023-09-12 22:42:05 | 2024-04-28 07:40:01 |
Judging History
answer
#include <bits/stdc++.h>
#ifndef CYBER
#include "closing.h"
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define lg long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const lg N= 2e5+5;
vector<array<lg, 2>> adj[N];
vector<lg> o;
lg lim = 0;
void dfs(lg src, lg par = -1, lg path = 0)
{
if(path > lim) return;
o.push_back(path);
for(auto [it, c] : adj[src])
{
if(it == par) continue;
dfs(it, src, path+c);
}
return;
}
int max_score(int n, int x, int y, lg k, vector<int> u, vector<int> v, vector<int> w)
{
int ans = 0;
lg linear = 1;
for(int i = 0; i < n-1; i++)
{
linear &= (i == u[i] && i+1 == v[i]);
}
x++, y++;
if(!linear)
{
for(int i = 1; i <= n; i++) adj[i].clear();
o.clear();
lim = k;
for(int i = 0; i < n-1; i++)
{
adj[u[i]].push_back({v[i], w[i]});
adj[v[i]].push_back({u[i], w[i]});
}
dfs(x);
dfs(y);
sort(o.begin(), o.end());
for(auto it : o)
{
k -= it;
if(k >= 0) ans++;
else break;
}
return ans;
}
lg a[n+2], b[n+2], c[n+2], d[n+2];
vector<lg> best[n+2];
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
memset(d, 0, sizeof(d));
for(int i = x-1; i >= 1; i--)
{
a[i] = a[i+1]+w[i-1];
}
for(int i = y-1; i >= 1; i--)
{
c[i] = c[i+1]+w[i-1];
}
for(int i = x+1; i <= n; i++)
{
b[i] = b[i-1]+w[i-2];
}
for(int i = y+1; i <= n; i++)
{
d[i] = d[i-1]+w[i-2];
}
for(int i = y; i <= n; i++)
{
lg gh = 0;
for(int j = i; j <= n; j++)
{
gh += d[j];
// cout << gh << ' ';
best[i].push_back(gh);
}
// cout << '\n';
}
lg sum = 0;
vector<lg> mxm(n+2);
for(int i = x; i >= 1; i--)
{
sum += max(0ll, a[i]-mxm[i]);
mxm[i] = max(mxm[i], a[i]);
vector<lg> fake3 = mxm;
lg o3 = sum;
for(int j = x; j <= n; j++)
{
sum += max(0ll, b[j]-mxm[j]);
mxm[j] = max(mxm[j], b[j]);
vector<lg> fake2 = mxm;
lg o2 = sum;
for(int z = y; z >= 1; z--)
{
sum += max(0ll, c[z]-mxm[z]);
mxm[z] = max(mxm[z], c[z]);
if(sum > k) continue;
int idx = max(y, j+1);
int g = upper_bound(best[idx].begin(), best[idx].end(), k-sum)-1-best[idx].begin();
// cout << k-sum << ' ' << idx << ' ' << g << ' ' << z << '\n';
ans = max(ans, j-i+g+idx-z+2);
}
mxm = fake2;
sum = o2;
}
mxm = fake3;
sum = o3;
}
return ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 69ms
memory: 25776kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 200000 31011 61157 8517583098 31011 129396 964383 1655 129396 331139 1655 191487 566483 110385 191487 865248 43212 110385 542661 43212 81682 13766 81682 91774 546589 91774 124706 780638 124706 175650 118706 10421 175650 615314 10421 151953 436270 140430 151...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 631
result:
wrong answer 1st lines differ - on the 1st token, expected: '451', found: '631'
Subtask #2:
score: 9
Accepted
Test #4:
score: 9
Accepted
time: 1ms
memory: 3752kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 23 25 382806473 0 1 375710 1 2 898637 2 3 10402 3 4 536577 4 5 385023 5 6 71075 6 7 543368 7 8 301497 8 9 174394 9 10 711312 10 11 923006 11 12 675532 12 13 838667 13 14 565729 14 15 979816 15 16 862618 16 17 576015 17 18 177751 18 19 306989 19 20 881492...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 96
result:
ok
Test #5:
score: 9
Accepted
time: 1ms
memory: 3816kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 47 20 22 25669694 0 1 291237 1 2 851987 2 3 421247 3 4 962919 4 5 643085 5 6 224951 6 7 756890 7 8 147295 8 9 625823 9 10 736374 10 11 290526 11 12 335466 12 13 539086 13 14 957449 14 15 423408 15 16 932444 16 17 356032 17 18 307118 18 19 94279 19 20 989546...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 26
result:
ok
Test #6:
score: 9
Accepted
time: 1ms
memory: 3872kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 46 6 34 355277954 0 1 574359 1 2 58362 2 3 778155 3 4 538832 4 5 128903 5 6 79774 6 7 715282 7 8 259924 8 9 640303 9 10 361135 10 11 506866 11 12 527045 12 13 946672 13 14 620381 14 15 701743 15 16 766266 16 17 524732 17 18 340089 18 19 630172 19 20 357712 ...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 74
result:
ok
Test #7:
score: 9
Accepted
time: 1ms
memory: 3872kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 45 14 44 70669 0 1 266130 1 2 372315 2 3 965349 3 4 119493 4 5 190522 5 6 506822 6 7 45330 7 8 423189 8 9 748532 9 10 653554 10 11 102552 11 12 90431 12 13 843259 13 14 422626 14 15 35334 15 16 1 16 17 1 17 18 1 18 19 1 19 20 1 20 21 1 21 22 1 22 23 1 23 24...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 4
result:
ok
Test #8:
score: 9
Accepted
time: 1ms
memory: 4076kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 0 49 332340134 0 1 987193 1 2 950856 2 3 893737 3 4 870689 4 5 810192 5 6 790242 6 7 744052 7 8 714922 8 9 677074 9 10 630082 10 11 599644 11 12 528415 12 13 491648 13 14 479486 14 15 439182 15 16 371085 16 17 357776 17 18 308161 18 19 254481 19 20 20430...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 44
result:
ok
Test #9:
score: 9
Accepted
time: 1ms
memory: 3804kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 0 49 329827838 0 1 972981 1 2 953594 2 3 908629 3 4 849675 4 5 808354 5 6 782643 6 7 759387 7 8 698618 8 9 650896 9 10 639153 10 11 591828 11 12 532588 12 13 503214 13 14 447660 14 15 403224 15 16 380834 16 17 327127 17 18 300115 18 19 244025 19 20 23362...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 44
result:
ok
Test #10:
score: 9
Accepted
time: 1ms
memory: 3804kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 3 0 1 1 0 1 1 1 2 1
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 3
result:
ok
Test #11:
score: 9
Accepted
time: 1ms
memory: 3836kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 20 8 9 31897732 0 1 428932 1 2 103619 2 3 805647 3 4 691922 4 5 320369 5 6 755877 6 7 701672 7 8 426711 8 9 507102 9 10 492732 10 11 68466 11 12 317311 12 13 37666 13 14 499673 14 15 502226 15 16 753200 16 17 523387 17 18 904778 18 19 695859
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 30
result:
ok
Test #12:
score: 9
Accepted
time: 0ms
memory: 4112kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 20 15 16 25160185 0 1 193268 1 2 139314 2 3 193167 3 4 446469 4 5 793626 5 6 502774 6 7 598587 7 8 69975 8 9 499282 9 10 943594 10 11 804459 11 12 536095 12 13 578060 13 14 142523 14 15 364845 15 16 181397 16 17 64327 17 18 224827 18 19 439557
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 26
result:
ok
Test #13:
score: 9
Accepted
time: 1ms
memory: 3868kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 20 0 19 77846543 0 1 603320 1 2 433257 2 3 572719 3 4 340716 4 5 549198 5 6 383420 6 7 50703 7 8 720210 8 9 304217 9 10 162280 10 11 68594 11 12 401595 12 13 446738 13 14 920882 14 15 494739 15 16 616729 16 17 874820 17 18 269830 18 19 53532
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 34
result:
ok
Test #14:
score: 9
Accepted
time: 1ms
memory: 3804kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 19 2 17 6692 0 1 748749 1 2 369010 2 3 3351 3 4 1 4 5 1 5 6 1 6 7 1 7 8 1 8 9 1 9 10 1 10 11 1 11 12 1 12 13 1 13 14 1 14 15 1 15 16 1 16 17 3346 17 18 11355
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 3
result:
ok
Subtask #3:
score: 12
Accepted
Dependency #2:
100%
Accepted
Test #15:
score: 12
Accepted
time: 1ms
memory: 3784kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 25 20 9 16 34385 0 1 196 1 2 733 2 3 758 3 4 92 4 5 636 5 6 462 6 7 491 7 8 239 8 9 873 9 10 983 10 11 72 11 12 988 12 13 690 13 14 162 14 15 287 15 16 247 16 17 121 17 18 140 18 19 64 20 9 13 37109 0 1 530 1 2 588 2 3 841 3 4 274 4 5 994 5 6 879 6 7 879 7 8 ...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 25 25 32 30 30 29 27 29 26 34 29 26 28 27 28 25 29 31 25 35 31 29 32 32 32
result:
ok
Test #16:
score: 12
Accepted
time: 77ms
memory: 4236kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 500 370 372 19501231139 0 1 617029 1 2 797198 2 3 612141 3 4 591522 4 5 350816 5 6 688732 6 7 453281 7 8 832047 8 9 259836 9 10 18218 10 11 771848 11 12 559096 12 13 175229 13 14 52243 14 15 644076 15 16 971271 16 17 808287 17 18 369695 18 19 213453 19 20 4...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 771
result:
ok
Test #17:
score: 12
Accepted
time: 0ms
memory: 4888kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 457 25 26 23461573 0 1 966726 1 2 347411 2 3 485905 3 4 803836 4 5 621204 5 6 767483 6 7 853669 7 8 510772 8 9 966639 9 10 221347 10 11 334454 11 12 553189 12 13 435896 13 14 294128 14 15 68783 15 16 492900 16 17 272820 17 18 566713 18 19 958845 19 20 28815...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 23
result:
ok
Test #18:
score: 12
Accepted
time: 94ms
memory: 3960kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 479 90 404 53062927890 0 1 698391 1 2 854901 2 3 299918 3 4 209753 4 5 125978 5 6 520489 6 7 823919 7 8 421785 8 9 57291 9 10 69394 10 11 44699 11 12 238062 12 13 272509 13 14 761088 14 15 488160 15 16 342026 16 17 452424 17 18 632018 18 19 387438 19 20 836...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 884
result:
ok
Test #19:
score: 12
Accepted
time: 2ms
memory: 4272kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 498 4 221 105089 0 1 463553 1 2 258066 2 3 685674 3 4 722140 4 5 52711 5 6 1 6 7 1 7 8 1 8 9 1 9 10 1 10 11 1 11 12 1 12 13 1 13 14 1 14 15 1 15 16 1 16 17 1 17 18 1 18 19 1 19 20 1 20 21 1 21 22 1 22 23 1 23 24 1 24 25 1 25 26 1 26 27 1 27 28 1 28 29 1 29 ...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 4
result:
ok
Test #20:
score: 12
Accepted
time: 2ms
memory: 3848kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 500 0 499 31632470564 0 1 997408 1 2 994454 2 3 991903 3 4 985530 4 5 983290 5 6 976711 6 7 974029 7 8 971703 8 9 966164 9 10 960060 10 11 958778 11 12 955381 12 13 951080 13 14 947500 14 15 942224 15 16 937350 16 17 935562 17 18 931918 18 19 924769 19 20 9...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 420
result:
ok
Test #21:
score: 12
Accepted
time: 2ms
memory: 4140kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 500 0 499 30660962655 0 1 998751 1 2 992763 2 3 990711 3 4 984240 4 5 981786 5 6 977311 6 7 972251 7 8 968449 8 9 964070 9 10 961182 10 11 959076 11 12 955656 12 13 950815 13 14 944555 14 15 941311 15 16 939818 16 17 932874 17 18 928498 18 19 927347 19 20 9...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 412
result:
ok
Test #22:
score: 12
Accepted
time: 1ms
memory: 3808kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 100 89 91 1462096533 0 1 639564 1 2 263322 2 3 868637 3 4 907132 4 5 701936 5 6 917697 6 7 934119 7 8 807575 8 9 601671 9 10 703969 10 11 258031 11 12 55044 12 13 582886 13 14 983102 14 15 339533 15 16 15472 16 17 166131 17 18 795004 18 19 139911 19 20 2922...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 173
result:
ok
Test #23:
score: 12
Accepted
time: 0ms
memory: 3864kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 99 6 8 23890628 0 1 571377 1 2 534743 2 3 176083 3 4 349821 4 5 464742 5 6 833949 6 7 635266 7 8 963766 8 9 824768 9 10 619251 10 11 816054 11 12 582962 12 13 24653 13 14 411247 14 15 83520 15 16 285010 16 17 823410 17 18 432273 18 19 701164 19 20 741379 20...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 18
result:
ok
Test #24:
score: 12
Accepted
time: 0ms
memory: 3760kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 91 17 72 1939374049 0 1 35118 1 2 685336 2 3 413418 3 4 979322 4 5 501149 5 6 760662 6 7 759104 7 8 153862 8 9 970666 9 10 51474 10 11 696373 11 12 851934 12 13 667521 13 14 912195 14 15 281874 15 16 525370 16 17 259093 17 18 401204 18 19 408960 19 20 14573...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 171
result:
ok
Test #25:
score: 12
Accepted
time: 1ms
memory: 4092kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 92 4 26 119573 0 1 441559 1 2 282137 2 3 328693 3 4 791088 4 5 59788 5 6 1 6 7 1 7 8 1 8 9 1 9 10 1 10 11 1 11 12 1 12 13 1 13 14 1 14 15 1 15 16 1 16 17 1 17 18 1 18 19 1 19 20 1 20 21 1 21 22 1 22 23 1 23 24 1 24 25 1 25 26 59786 26 27 814959 27 28 250969...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 4
result:
ok
Test #26:
score: 12
Accepted
time: 1ms
memory: 4056kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 100 0 99 1246775789 0 1 984791 1 2 976898 2 3 941834 3 4 936109 4 5 914832 5 6 897530 6 7 873365 7 8 858001 8 9 836532 9 10 804954 10 11 790654 11 12 770728 12 13 741299 13 14 728310 14 15 705679 15 16 685271 16 17 672680 17 18 657701 18 19 624301 19 20 605...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 84
result:
ok
Test #27:
score: 12
Accepted
time: 0ms
memory: 3804kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 100 0 99 1343862634 0 1 983240 1 2 979635 2 3 956181 3 4 922454 4 5 908815 5 6 889339 6 7 860241 7 8 858057 8 9 823141 9 10 814027 10 11 799313 11 12 767645 12 13 757119 13 14 733433 14 15 709785 15 16 683477 16 17 669417 17 18 646073 18 19 633866 19 20 602...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 88
result:
ok
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #3:
100%
Accepted
Test #28:
score: 14
Accepted
time: 3ms
memory: 4160kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 60 50 1 40 432415399 0 1 368374 1 2 617489 2 3 306692 3 4 798376 4 5 793297 5 6 739002 6 7 827272 7 8 36264 8 9 734569 9 10 348508 10 11 330646 11 12 207010 12 13 915258 13 14 860319 14 15 979734 15 16 380786 16 17 247273 17 18 379557 18 19 570364 19 20 88142...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 75 75 75 71 72 75 77 77 75 77 76 72 77 76 80 75 74 74 74 72 79 80 74 76 79 78 76 75 70 75 78 70 70 77 77 75 72 79 80 74 74 77 75 76 77 74 73 70 76 79 73 74 72 70 72 75 77 75 79 73
result:
ok
Test #29:
score: 0
Time Limit Exceeded
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 3000 2070 2072 1089598154219 0 1 122799 1 2 916338 2 3 195082 3 4 407254 4 5 870644 5 6 481623 6 7 981840 7 8 866223 8 9 620294 9 10 769645 10 11 402571 11 12 139469 12 13 712968 13 14 922546 14 15 258282 15 16 396994 16 17 976517 17 18 236766 18 19 643813 ...
output:
result:
Subtask #5:
score: 0
Wrong Answer
Test #36:
score: 0
Wrong Answer
time: 1ms
memory: 3816kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 4 0 1 9 0 2 2 1 2 3 2 3 3
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 5
result:
wrong answer 1st lines differ - on the 1st token, expected: '6', found: '5'
Subtask #6:
score: 0
Skipped
Dependency #2:
100%
Accepted
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
100%
Accepted
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #4:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%