QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#883541 | #9643. 串联 | hos_lyric# | 30 | 1107ms | 19112kb | C++14 | 2.3kb | 2025-02-05 16:50:45 | 2025-02-05 16:50:48 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
constexpr Int INF = 1001001001001001001LL;
int N;
Int T;
vector<Int> C, D;
vector<int> A, B;
vector<vector<int>> graph;
namespace brute {
Int ans;
void dfs(int u, int p, Int c, Int d) {
if ((__int128)c * d >= T) {
chmin(ans, d);
return;
}
for (const int v : graph[u]) if (p != v) {
dfs(v, u, min(c, C[v]), d + D[v]);
}
}
Int run() {
ans = INF;
for (int u = 0; u < N; ++u) dfs(u, -1, C[u], D[u]);
return ans;
}
} // brute
int main() {
for (; ~scanf("%d%lld", &N, &T); ) {
C.resize(N);
D.resize(N);
for (int u = 0; u < N; ++u) {
scanf("%lld%lld", &C[u], &D[u]);
}
A.resize(N - 1);
B.resize(N - 1);
for (int i = 0; i < N - 1; ++i) {
scanf("%d%d", &A[i], &B[i]);
--A[i];
--B[i];
}
graph.assign(N, {});
for (int i = 0; i < N - 1; ++i) {
graph[A[i]].push_back(B[i]);
graph[B[i]].push_back(A[i]);
}
const Int ans = brute::run();
printf("%lld\n", ans);
}
return 0;
}
详细
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 11ms
memory: 3968kb
input:
1935 100002617107042 3549526 1627445 3659278 5231179 8300710 6537126 3692477 4253254 2314646 7374383 9557660 3973510 2157299 8008856 5349338 9286378 6863965 5295468 6438473 3472437 8623469 5151533 6732744 5135250 9763341 4477819 1198507 4326984 4085755 8151510 4127916 9559825 5382178 3509576 9971869...
output:
10479936
result:
ok single line: '10479936'
Test #2:
score: 15
Accepted
time: 16ms
memory: 3840kb
input:
1971 100000691996565 2103598 9622163 4487235 8720445 4380307 7057318 6240155 8766658 4184502 7515423 1704463 8584340 2811007 6951160 9512006 2266117 8362504 2068427 4229112 8941299 2952150 7792204 1581088 4384220 5994528 4226903 1604304 7007689 9600169 1335687 8370604 5157219 7460688 4960477 6914930...
output:
11141504
result:
ok single line: '11141504'
Test #3:
score: 15
Accepted
time: 19ms
memory: 3968kb
input:
1983 100001553850439 1390471 8373725 4152152 8011586 7880235 4867329 6598575 4598523 7678550 5553716 1573498 7813596 6956498 5940329 5294850 3021950 8553807 1030010 2076488 5534459 1182084 6855575 8387158 7722486 6071583 2464277 8286289 4885466 1936319 3174207 3189515 1366768 9753540 3317719 3849662...
output:
10701114
result:
ok single line: '10701114'
Test #4:
score: 15
Accepted
time: 21ms
memory: 3968kb
input:
1927 100003351938229 3192275 3299496 5630684 3516336 4476042 3507988 7722775 6169426 8178348 8283137 3439079 2122873 5961233 7356897 1254487 4619254 4838418 4236218 6415837 3011434 8007562 9870183 1552526 2559813 5044863 4711889 8088368 9594874 3797519 2845637 5441391 8511329 4497382 3845760 3105856...
output:
11317746
result:
ok single line: '11317746'
Test #5:
score: 15
Accepted
time: 18ms
memory: 3968kb
input:
1987 100001330852095 5762711 6136317 3231303 3551982 4927533 5867528 1817360 9880735 9796958 7054450 7600257 4630508 8108348 3560218 5385906 8297160 3174098 4875077 6083307 3562721 1122501 9373766 9875657 7477320 4540883 5896453 2965472 2786388 8144966 1723495 4677343 3451774 9358401 4255211 4910602...
output:
11064293
result:
ok single line: '11064293'
Test #6:
score: 15
Accepted
time: 14ms
memory: 3968kb
input:
1995 100003379470494 2159064 3993567 6204650 7163106 4467952 8805337 8012214 7073506 3105001 5990175 8648815 7123912 9968824 7532393 4329742 3413342 3931287 1566236 9723607 9589428 4175044 8949341 5554633 7186564 9187055 5287217 8702434 7939849 8002894 2482586 5080559 9567363 4610537 9890149 1626511...
output:
11506703
result:
ok single line: '11506703'
Test #7:
score: 15
Accepted
time: 16ms
memory: 3968kb
input:
1982 100000767594946 5597760 3847159 1583159 3021842 5581632 1526220 2343244 7031674 4027561 3006768 7918430 9266709 7208210 1341347 8082640 9960766 3102443 6738794 2918486 4572414 5759220 1561720 8039985 6072471 1615189 2584807 9356345 3161984 3101051 3869417 1917321 7317457 4488365 2266216 4403623...
output:
11212936
result:
ok single line: '11212936'
Test #8:
score: 15
Accepted
time: 10ms
memory: 3968kb
input:
1945 100000772724254 9865667 4167237 2107080 5511704 5187488 5793540 5224042 3028952 1496025 5739774 4760433 4904976 8244458 9546030 3622460 3183192 3987254 6318700 5324961 8835334 5837449 9939171 6723269 1222576 1099080 2639246 8477992 1541119 2946621 4777441 9402894 7755943 8468016 4315963 4816187...
output:
10869957
result:
ok single line: '10869957'
Test #9:
score: 15
Accepted
time: 17ms
memory: 3840kb
input:
1930 100000451326765 1039106 5121964 7987282 6829062 6938347 7503664 9750466 8945093 9470902 8311859 1625601 3347631 4642526 6762428 4779574 4961568 1954217 9232868 5441223 8438035 2505709 7671901 1067803 5420751 6942082 1845724 7546254 7917525 1026887 4934622 1915427 4073952 7603783 1190044 4167032...
output:
11239000
result:
ok single line: '11239000'
Test #10:
score: 15
Accepted
time: 11ms
memory: 3968kb
input:
1913 100003814692834 7059545 4499258 2551512 7336099 4351441 4600396 6915747 6908156 3891860 9095088 3315314 2911686 9888472 5690580 1434904 5625736 7403892 4145739 2994494 6319247 7123772 2307216 4109002 5381243 5582054 6674569 8508045 9463027 8582113 5134882 1917706 5709360 3640259 2599766 8461399...
output:
10428958
result:
ok single line: '10428958'
Test #11:
score: 15
Accepted
time: 12ms
memory: 4096kb
input:
2000 443873123 4438732 1 7073 73057 8334 6810 4438732 1 4438732 1 4438732 1 4438732 1 7959 34772 4438732 1 4779 74771 4825 1826 4114 82622 7515 55610 3553 75085 1663 43103 4438732 1 4438732 1 4438732 1 9488 17416 4438732 1 4438732 1 4438732 1 8882 54476 3892 29429 4438732 1 3852 99676 4438732 1 7720...
output:
100
result:
ok single line: '100'
Test #12:
score: 15
Accepted
time: 44ms
memory: 4096kb
input:
2000 2567102235 1951 78228 2929 44714 256713 1 3228 21668 3195 19367 256713 1 423 60941 7318 39217 256713 1 1771 36243 538 77624 4770 69714 353 54372 4538 61165 3563 60485 8820 61683 3299 58688 4984 10128 256713 1 2423 88726 256713 1 256713 1 256713 1 256713 1 3730 64799 256713 1 6020 4453 256713 1 ...
output:
386206
result:
ok single line: '386206'
Test #13:
score: 15
Accepted
time: 42ms
memory: 4096kb
input:
2000 1726807031 3651 27424 8668 29785 726808 1 8026 12235 9532 33835 7628 73709 981 91763 4457 54863 8019 91030 2532 38289 1956 52813 2311 66731 2486 62485 6666 75306 6860 83276 726808 1 359 26614 726808 1 726808 1 7511 44459 644 47378 9701 97996 726808 1 726808 1 726808 1 726808 1 726808 1 726808 1...
output:
215066
result:
ok single line: '215066'
Subtask #2:
score: 15
Accepted
Test #14:
score: 15
Accepted
time: 323ms
memory: 4416kb
input:
9772 100001635009487 6105477 9592965 2446558 4081788 3544307 1498494 1158072 8593648 2722648 8107870 7463502 6028672 1128603 1768366 2691462 2490920 1577521 7479612 4254188 3702455 2401701 1962198 6092604 6450289 9341997 6406106 1917654 5247247 6146524 7167452 3394606 7672593 9007250 7454473 6281744...
output:
10781826
result:
ok single line: '10781826'
Test #15:
score: 15
Accepted
time: 391ms
memory: 4320kb
input:
9066 100004226621364 1740518 6601687 3921518 7818908 3706648 9433445 9974006 6400908 8624646 9927553 7171517 4099662 2889954 9420495 9535765 4082011 9274713 2251055 8108453 8199095 2046416 4032639 4828543 8449524 4218737 2216220 5658160 9114351 2627227 5010812 7563956 7828528 6217342 3286955 4569753...
output:
10986553
result:
ok single line: '10986553'
Test #16:
score: 15
Accepted
time: 265ms
memory: 4444kb
input:
9391 100001393244059 3253884 9527331 9717791 2528608 6181718 7283607 7011819 8414728 2973564 4566253 8341749 1949256 3934392 7753162 4150295 8444978 6963461 5328778 3643536 1432145 2629996 2395914 7870489 3754759 1806604 2313573 7085332 3241652 7848175 2573848 5457876 9004241 4242330 8085049 3620819...
output:
10940902
result:
ok single line: '10940902'
Test #17:
score: 15
Accepted
time: 527ms
memory: 4456kb
input:
9626 100000166942620 6442651 1826623 9247400 9192956 9995909 2979009 4857697 4094447 2882631 8039904 4567976 6654287 6508049 4137114 6075019 3410952 2219353 8975890 3527328 7729220 5215177 3537904 6860256 6621101 6949818 6305955 8562902 9039534 9764253 6946659 1210328 9676433 4508417 1319169 7941971...
output:
10375768
result:
ok single line: '10375768'
Test #18:
score: 15
Accepted
time: 204ms
memory: 4456kb
input:
9657 100000488448934 8511937 9704622 1806100 5040809 2435873 6868975 2325756 6847822 1471700 1374442 7993438 2893382 1032591 8604218 8295227 7464026 5025473 1824040 7792443 3664155 2917212 1969873 5308415 6972573 3755415 6866651 3351919 3378288 7856957 9137960 2786068 6349657 2300599 1566738 1694163...
output:
10636860
result:
ok single line: '10636860'
Test #19:
score: 15
Accepted
time: 430ms
memory: 4408kb
input:
9348 100004235713160 5126441 1253529 6942942 3856766 7407585 7721822 8513019 1216794 4047246 4090116 5816382 2509972 9675824 6801988 4690536 8004954 7655640 2530479 1747055 3816210 5300653 6494315 9355817 2318301 7280072 4964662 7826825 5981332 2578934 1799645 4848406 2771896 5719873 1534262 4558994...
output:
10499519
result:
ok single line: '10499519'
Test #20:
score: 15
Accepted
time: 420ms
memory: 4448kb
input:
9456 100002206594852 3156631 9931295 5822353 2346521 8048079 7266800 4908659 6362162 5670151 2762237 7210862 1054494 9015700 9178386 2345527 7738445 7274032 1557525 6161488 9662995 9516708 9611955 7774878 2383767 1493592 5772094 5971863 7336123 3735655 2147182 3350987 8358656 3298763 2682458 9692438...
output:
10347385
result:
ok single line: '10347385'
Test #21:
score: 15
Accepted
time: 294ms
memory: 4448kb
input:
9462 100000788713534 7239653 1567369 4304815 9097724 6133358 8088013 5519769 7568531 3654555 4934633 5406560 5138219 9022789 4106442 2130871 4791129 7595297 5521654 3015487 2419454 5991474 8509611 9403962 7756231 6084874 7185277 9399911 8613005 5670807 8341400 3335880 1132131 6369388 8787347 7760834...
output:
10688383
result:
ok single line: '10688383'
Test #22:
score: 15
Accepted
time: 384ms
memory: 4444kb
input:
9398 100001152419719 4331712 3433495 4215238 9839512 4083618 4238298 6497946 6004662 7510645 7752425 3224753 8729343 3020351 9313282 6312319 6615149 2889403 1093187 2058189 3399107 2796341 6705883 6347810 4782243 1586370 1794209 8568264 5579196 7299121 8971413 4153208 9616157 3102096 4903930 7200903...
output:
10792821
result:
ok single line: '10792821'
Test #23:
score: 15
Accepted
time: 216ms
memory: 4460kb
input:
9678 100003731533383 6209408 9856769 3907282 6918838 7350593 8918458 7867585 3393227 5951178 5056676 7899496 3544094 1548735 9463181 5998525 8854409 8235863 9565462 7959507 4370000 6135923 1478337 6636253 7450874 1907658 9717043 5250115 3148181 9410458 3620397 6242029 7947947 6818297 1122671 6484804...
output:
10524587
result:
ok single line: '10524587'
Test #24:
score: 15
Accepted
time: 1107ms
memory: 4692kb
input:
9000 2546287870 565842 1 565842 1 8692 52515 8197 3696 4215 38675 565842 1 4219 85145 204 7182 565842 1 565842 1 565842 1 565842 1 565842 1 7436 51080 565842 1 6031 82307 565842 1 7993 50214 7709 85541 565842 1 5503 39 4018 21312 565842 1 9972 89387 7972 43318 6424 88027 565842 1 565842 1 565842 1 6...
output:
315565
result:
ok single line: '315565'
Test #25:
score: 15
Accepted
time: 1101ms
memory: 4608kb
input:
9000 3577471707 794994 1 7187 97693 794994 1 794994 1 794994 1 794994 1 794994 1 794994 1 6088 54736 794994 1 858 3646 794994 1 4325 49145 794994 1 8828 8981 308 42518 1301 15269 794994 1 1269 18105 794994 1 794994 1 794994 1 794994 1 2562 8297 794994 1 794994 1 7769 81285 7438 72582 794994 1 794994...
output:
536706
result:
ok single line: '536706'
Test #26:
score: 15
Accepted
time: 1096ms
memory: 4476kb
input:
9000 4710817005 1046849 1 1046849 1 6400 81586 3297 80662 1046849 1 1046849 1 7236 38208 8892 2922 2227 38475 1046849 1 1766 5068 6687 96287 511 44892 1046849 1 1046849 1 6669 70465 1046849 1 1046849 1 1046849 1 876 39982 1046849 1 7213 16152 6286 3332 3797 16918 1046849 1 2239 65591 3749 25028 8134...
output:
646319
result:
ok single line: '646319'
Subtask #3:
score: 0
Time Limit Exceeded
Test #27:
score: 0
Time Limit Exceeded
input:
199998 100004130186324 3352699 4354450 7345378 4717865 6884528 5360708 8446213 6146508 8452875 8731152 9911476 8488596 5132982 8228726 2511731 8301731 7950999 4157882 9453240 2023463 7037057 9438422 9440756 2823577 9759370 9536497 7953412 4176946 2271735 3600297 1933248 1696214 3170616 9708900 85838...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #40:
score: 15
Accepted
time: 49ms
memory: 19112kb
input:
199990 10003188838297 4211327 3820876 7698984 8359653 5066640 7948487 8284258 7942725 1523122 8506553 8839078 3332090 2286508 2775336 2137304 5706348 5156807 1709018 1370762 6336028 4873462 5648510 1731080 9104872 9546417 3513558 8372504 5527023 1886687 8042824 7075090 8975678 7078482 8268817 547400...
output:
1008614
result:
ok single line: '1008614'
Test #41:
score: 15
Accepted
time: 51ms
memory: 19108kb
input:
199999 10002892355528 5616464 2944799 5772471 7437719 6455477 1153785 8845516 1736216 7541571 6737585 6753821 4807148 7443244 1663563 2095696 4467453 4368446 7743374 8259067 9071855 4734198 1482386 7480742 4656492 4934179 3922246 9913203 6156126 3403717 6473378 7676983 2227587 4479830 4041223 368774...
output:
1007012
result:
ok single line: '1007012'
Test #42:
score: 15
Accepted
time: 50ms
memory: 19108kb
input:
199997 10002540820180 2754035 9858195 1595534 2907220 4946408 8642691 7896342 1300619 5111215 7329949 4088966 2809675 9679494 6112691 2577541 4528373 1879949 8536567 1829262 4177071 3844112 9633619 7640307 8952100 7701837 4556731 9749883 9712552 2713201 6204511 7520267 1230545 6569198 3921105 565105...
output:
1010168
result:
ok single line: '1010168'
Test #43:
score: 15
Accepted
time: 47ms
memory: 19104kb
input:
199997 10004112875807 6921794 2508174 9118576 5783130 6189752 5065631 6769433 6894201 6233398 4248171 8452881 4197303 2573176 7798809 6402462 6799228 7331875 1796377 6646698 5237625 7281887 1049730 6914159 5311568 2181386 2057139 1459456 5580607 6943011 9522460 3065862 4971688 6568179 5762797 505170...
output:
1009449
result:
ok single line: '1009449'
Test #44:
score: 15
Accepted
time: 49ms
memory: 19080kb
input:
199991 10001724540843 4491882 1453695 4356435 3409089 6855752 8219883 6430172 1614670 3843148 1022645 4269813 7258614 5244547 9207415 3845135 4562284 1695124 5869919 4001271 9528847 5020509 9774407 9513114 3495639 2982036 6693341 9503117 1179466 8083309 3824054 6695164 7547434 1541019 2999212 533629...
output:
1006038
result:
ok single line: '1006038'
Test #45:
score: 15
Accepted
time: 50ms
memory: 19108kb
input:
199999 10000389140505 3680143 4839269 7873331 5843155 5763444 1776610 7952234 8357516 7867978 5690313 8627617 3586698 5821751 1011367 9430152 1979769 9149950 8872531 2691551 2314677 8818458 1067616 5445138 2612596 2643010 3270830 2336588 8448919 3769434 8303475 9507925 1676238 8661829 5446050 910339...
output:
1007783
result:
ok single line: '1007783'
Test #46:
score: 15
Accepted
time: 50ms
memory: 18936kb
input:
199994 10003636621292 9946882 3223288 6515088 9195492 8277841 3457848 4069679 1215207 7181644 7823713 3472846 7725111 4988995 8844252 6216786 2885600 9224549 5839119 2734798 8204235 4723466 3990811 7940052 6774106 3155510 7632144 8266153 2675956 6529839 2762325 3418256 6580832 8346492 2389404 903124...
output:
1010104
result:
ok single line: '1010104'
Test #47:
score: 15
Accepted
time: 51ms
memory: 19104kb
input:
199994 10002185448805 7781921 6978590 1010673 9623739 7819541 6654644 7790666 6221961 9048824 7665354 7873449 1969643 8741447 4281216 6486632 6783074 4103765 9784839 9626058 5247565 5713991 1593716 8773484 9114570 8903689 8907538 1731278 2469311 1800416 1233909 2448508 6155251 8232167 8846978 930738...
output:
1008427
result:
ok single line: '1008427'
Test #48:
score: 15
Accepted
time: 49ms
memory: 18940kb
input:
199997 10001386420983 8066582 1147291 6651364 3490714 7337487 3128455 3502395 4057361 9107246 6859397 8616442 9207941 3284920 5977517 6392479 8004977 1606988 3269444 7463397 5722977 6626564 6188500 9083616 5542187 8615236 5414984 2055744 2346462 9233048 8889314 1377785 2484192 7816741 4853641 529468...
output:
1006587
result:
ok single line: '1006587'
Test #49:
score: 15
Accepted
time: 46ms
memory: 19064kb
input:
199997 10003846281617 9863808 8749861 8291906 3652162 8922421 9888378 6786126 7376908 2643872 5727827 8487239 5819553 3023723 8337888 6486663 9801774 5696617 6457997 3410735 2459783 9306526 8266016 5918224 4881120 9746442 9177364 7839090 4649236 5372951 5013269 3557565 9080622 1202016 8287845 729980...
output:
1003586
result:
ok single line: '1003586'
Test #50:
score: 0
Time Limit Exceeded
input:
200000 5003203842030 90768 425892 139402 114145 427635 950672 635764 247663 550279 598107 909639 361897 706306 377873 662140 222260 77403 246946 877677 1874 121969 618959 991479 517325 224525 329398 852256 177688 666055 719211 335497 552386 597746 593476 562488 677214 725310 409879 477054 856893 567...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #53:
score: 0
Time Limit Exceeded
input:
49990 100000994385852 8754571 7380604 2240806 6151788 3314007 8112341 6984100 8481029 1194110 4487530 6444114 5193786 5723011 8911491 9068179 9599365 9949744 6860180 3973585 2935971 9594995 4665326 7245966 1871321 9147881 9702198 6028928 7824679 3618152 5786003 5979819 9771693 1794062 1126052 135005...
output:
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #67:
score: 0
Time Limit Exceeded
input:
199990 100004231755893 8188750 4873620 4552453 6246559 9803815 8778380 7562427 7965226 4387027 7384336 4591418 7954720 2314277 7137407 3606907 4028084 6999739 4472967 4802931 4761929 1437045 7520376 5023737 7211510 7897214 6615679 4438283 6095313 6433812 6877440 9470655 1578766 4363540 1827990 62248...