ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#194483 | #3410. 百日草 | Zeardoe | 100 | 4221ms | 19724kb | C++11 | 2.2kb | 2023-10-15 15:26:03 | 2023-10-15 18:48:27 |
answer
/*
[templates]:
duipai
spjdp
compre
addhis
floor_sum
treedfs
matrix
network_flow
polynomial
lca
bitset
valuesgt
fenwick
erbitree
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//use ll instead of int.
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e18;
//#define cerr if(false)cerr
//#define freopen if(false)freopen
mt19937 rng(time(0));
int rnd(int l, int r) {return rng() % (r-l+1) + l; }
#define watch(x) cerr << (#x) << ' '<<'i'<<'s'<<' ' << x << endl
void pofe(int number, int bitnum) {
string s; f(i, 0, bitnum) {s += char(number & 1) + '0'; number >>= 1; }
reverse(s.begin(), s.end()); cerr << s << endl;
return;
}
template <typename TYP> void cmax(TYP &x, TYP y) {if(x < y) x = y;}
template <typename TYP> void cmin(TYP &x, TYP y) {if(x > y) x = y;}
//调不出来给我对拍!
//use std::array.
vector<pii> g[300200]; int n, m; int dis[300030];
bool ok(int mid) {
queue<int> q; q.push(1);
f(i, 1, n) dis[i] = inf;
dis[1] = 0;
while(!q.empty()) {
int now = q.front(); q.pop();
if(now == n) return 1;
for(pii i : g[now]) {
if(dis[i.first] != inf) continue;
if(i.second * (dis[now] + 1) > mid) continue;
dis[i.first] = dis[now] + 1;
q.push(i.first);
}
}
return 0;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
//freopen();
//freopen();
//time_t start = clock();
//think twice,code once.
//think once,debug forever.
cin >> n >> m;
f(i, 1, m) {
int a, b, c; cin >> a >> b >> c;
g[a].push_back({b, c});
}
int lo = 0, hi = 3e14;
while(lo < hi) {
int mid = (lo + hi) >> 1;
if(ok(mid)) hi = mid;
else lo = mid + 1;
}
cout << lo << endl;
//time_t finish = clock();
//cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 0ms
memory: 8292kb
input:
9 9 6 7 9787 8 9 4122 7 8 5040 5 6 1482 1 2 7190 4 5 1900 2 3 3416 1 8 236 3 4 3396
output:
8244
result:
ok answer is '8244'
Test #2:
score: 0
Accepted
time: 3ms
memory: 8296kb
input:
20 20 15 1 10000 18 19 8888 11 12 10000 1 2 10000 5 6 10000 16 17 9999 10 11 10000 12 13 10000 15 16...
output:
159984
result:
ok answer is '159984'
Test #3:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
13 15 10 10 5052 7 8 4062 8 9 7905 10 11 9548 6 7 4168 1 2 2433 4 5 8785 5 6 273 11 12 3305 13 3 394...
output:
95480
result:
ok answer is '95480'
Test #4:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
14 14 10 11 3713 1 2 7086 5 6 354 5 1 7463 6 7 6860 4 5 4018 12 13 4492 11 12 2644 9 10 7373 2 3 480...
output:
66357
result:
ok answer is '66357'
Test #5:
score: 0
Accepted
time: 3ms
memory: 8292kb
input:
14 18 7 8 2063 11 12 5699 8 9 3589 5 13 9778 6 3 2842 12 13 8563 4 5 918 9 10 5277 9 3 5495 5 6 6573...
output:
48890
result:
ok answer is '48890'
Test #6:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
9 9 8 9 5654 2 3 568 6 8 1099 6 7 9522 3 4 965 1 2 1742 5 6 9401 7 8 3089 4 5 2165
output:
47005
result:
ok answer is '47005'
Test #7:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
2 2 1 1 5882 1 2 2417
output:
2417
result:
ok answer is '2417'
Test #8:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
20 20 14 15 10000 4 5 10000 8 9 10000 5 6 10000 7 8 10000 16 17 10000 11 12 10000 15 16 10000 2 3 10...
output:
160000
result:
ok answer is '160000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
15 15 4 5 10000 13 14 10000 7 8 10000 8 9 10000 2 3 10000 15 14 10000 12 13 10000 10 11 10000 6 7 10...
output:
140000
result:
ok answer is '140000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
13 13 1 2 4220 7 8 7036 2 3 7328 4 4 8301 10 11 2664 4 5 3148 11 12 4128 9 10 3924 6 7 927 12 13 389...
output:
51392
result:
ok answer is '51392'
Test #11:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
13 19 9 10 1858 4 5 463 3 1 7074 4 8 6861 5 1 7547 5 9 7809 12 6 1252 7 8 642 1 2 6591 5 6 12 2 3 33...
output:
56964
result:
ok answer is '56964'
Test #12:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
3 10 1 3 10000 3 3 10000 3 2 10000 1 3 10000 1 1 10000 2 1 10000 1 2 10000 2 3 10000 3 1 10000 3 1 1...
output:
10000
result:
ok answer is '10000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
15 15 7 8 10000 4 5 10000 8 9 10000 12 13 10000 6 7 10000 9 10 10000 10 11 10000 1 2 10000 11 12 100...
output:
140000
result:
ok answer is '140000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
18 18 14 15 2582 4 5 1324 7 8 5212 15 16 8059 1 2 7422 12 13 6371 10 11 4269 6 7 2785 9 10 8039 2 3 ...
output:
134419
result:
ok answer is '134419'
Test #15:
score: 0
Accepted
time: 4ms
memory: 8292kb
input:
18 20 13 14 6084 14 15 2248 9 10 6359 4 5 251 5 6 6473 9 11 998 1 2 4437 7 8 700 6 7 3836 17 18 1560...
output:
73304
result:
ok answer is '73304'
Subtask #2:
score: 20
Accepted
Test #16:
score: 20
Accepted
time: 3ms
memory: 8296kb
input:
94 94 82 83 5851 6 7 6277 49 50 1953 53 54 259 56 57 6783 17 18 9933 40 41 6467 48 49 2008 12 13 870...
output:
844432
result:
ok answer is '844432'
Test #17:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
20 93 1 8 10000 13 1 10000 20 1 10000 8 8 10000 2 3 10000 5 14 10000 15 16 10000 15 17 10000 15 19 1...
output:
20000
result:
ok answer is '20000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
69 81 66 67 8227 2 3 9743 16 17 2965 48 49 3583 57 15 1919 3 4 2169 14 15 7696 12 13 4417 53 54 3093...
output:
82270
result:
ok answer is '82270'
Test #19:
score: 0
Accepted
time: 1ms
memory: 8296kb
input:
45 45 29 30 6683 32 33 748 7 8 3532 23 24 1274 3 4 6326 44 45 1242 27 28 880 37 38 7360 16 17 6784 1...
output:
428366
result:
ok answer is '428366'
Test #20:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
48 91 40 41 248 38 4 263 16 17 625 16 45 625 7 8 1428 3 33 3333 39 40 254 21 22 475 29 30 343 2 28 4...
output:
10000
result:
ok answer is '10000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
63 73 10 11 10000 63 34 10000 17 59 10000 21 22 10000 58 59 10000 19 19 10000 1 2 10000 46 37 10000 ...
output:
200000
result:
ok answer is '200000'
Test #22:
score: 0
Accepted
time: 3ms
memory: 8292kb
input:
83 83 2 3 10000 45 46 10000 54 55 10000 61 53 10000 5 6 10000 23 24 10000 38 39 10000 50 51 10000 28...
output:
820000
result:
ok answer is '820000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
59 88 56 57 10000 26 27 10000 5 43 10000 18 15 10000 35 36 10000 36 42 10000 47 19 10000 35 17 10000...
output:
160000
result:
ok answer is '160000'
Test #24:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
36 38 31 32 2578 25 26 3198 27 28 2960 28 29 2856 13 6 6152 30 31 2666 1 2 10000 33 13 2424 20 21 40...
output:
80000
result:
ok answer is '80000'
Test #25:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
64 64 53 54 10000 9 10 10000 38 39 10000 40 41 10000 30 31 10000 50 13 10000 2 3 10000 11 12 10000 4...
output:
630000
result:
ok answer is '630000'
Test #26:
score: 0
Accepted
time: 3ms
memory: 8296kb
input:
23 62 1 2 10000 11 12 10000 13 14 10000 8 17 10000 19 23 10000 6 22 10000 22 19 10000 3 4 10000 9 10...
output:
40000
result:
ok answer is '40000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
49 98 42 43 6825 32 33 4343 47 48 2768 14 15 4269 1 35 8020 36 29 4665 27 28 9312 2 3 9373 45 46 605...
output:
34955
result:
ok answer is '34955'
Test #28:
score: 0
Accepted
time: 0ms
memory: 8292kb
input:
10 10 5 6 2157 3 4 9449 4 5 6614 6 7 8181 9 10 570 2 3 7859 8 9 2803 7 8 2950 10 2 4363 1 2 8338
output:
49086
result:
ok answer is '49086'
Test #29:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
71 100 36 66 10000 3 4 10000 40 41 10000 60 50 10000 16 20 10000 7 23 10000 45 62 10000 17 18 10000 ...
output:
80000
result:
ok answer is '80000'
Test #30:
score: 0
Accepted
time: 0ms
memory: 8296kb
input:
23 89 17 18 10000 4 1 10000 2 3 10000 11 12 10000 22 18 10000 9 10 10000 1 5 10000 4 7 10000 21 22 1...
output:
30000
result:
ok answer is '30000'
Subtask #3:
score: 20
Accepted
Test #31:
score: 20
Accepted
time: 0ms
memory: 8360kb
input:
1391 1391 685 686 1000000000 528 529 1000000000 1360 1361 1000000000 294 295 1000000000 317 318 1000...
output:
1390000000000
result:
ok answer is '1390000000000'
Test #32:
score: 0
Accepted
time: 0ms
memory: 8360kb
input:
533 1687 299 300 297497169 245 156 459224728 62 63 469281415 122 320 912731332 269 338 708463233 173...
output:
2160446904
result:
ok answer is '2160446904'
Test #33:
score: 0
Accepted
time: 0ms
memory: 8360kb
input:
1160 1427 1116 1117 1792113 1039 207 1924926 458 459 4366811 857 858 2333721 124 125 16129030 364 74...
output:
1999999996
result:
ok answer is '1999999996'
Test #34:
score: 0
Accepted
time: 0ms
memory: 8356kb
input:
1201 1201 139 140 846309564 202 203 499522645 1116 1117 584154854 1141 1142 490228546 226 227 611129...
output:
1149018642044
result:
ok answer is '1149018642044'
Test #35:
score: 0
Accepted
time: 4ms
memory: 8312kb
input:
323 602 27 134 1000000000 131 276 1000000000 12 13 1000000000 139 140 1000000000 184 244 1000000000 ...
output:
10000000000
result:
ok answer is '10000000000'
Test #36:
score: 0
Accepted
time: 0ms
memory: 8320kb
input:
449 663 110 41 568920729 316 317 675253969 405 406 101431336 147 148 485193573 357 358 132551254 314...
output:
9342867700
result:
ok answer is '9342867700'
Test #37:
score: 0
Accepted
time: 5ms
memory: 8328kb
input:
527 527 7 8 1000000000 67 68 1000000000 178 179 1000000000 389 390 1000000000 205 206 1000000000 169...
output:
426000000000
result:
ok answer is '426000000000'
Test #38:
score: 0
Accepted
time: 0ms
memory: 8340kb
input:
182 1173 34 81 389286806 128 52 683306358 43 35 902829956 85 108 252197643 61 151 896763607 133 30 8...
output:
813776556
result:
ok answer is '813776556'
Test #39:
score: 0
Accepted
time: 0ms
memory: 8376kb
input:
1255 1891 805 806 1000000000 291 292 1000000000 46 47 1000000000 580 153 1000000000 983 86 100000000...
output:
19000000000
result:
ok answer is '19000000000'
Test #40:
score: 0
Accepted
time: 0ms
memory: 8336kb
input:
814 814 740 741 785906947 676 677 64634118 789 790 30861187 499 500 291257245 546 547 593568047 612 ...
output:
796479770898
result:
ok answer is '796479770898'
Test #41:
score: 0
Accepted
time: 5ms
memory: 8324kb
input:
234 790 142 143 31360215 139 140 769004821 117 118 495907298 154 81 293953955 168 74 344970431 209 2...
output:
1832029542
result:
ok answer is '1832029542'
Test #42:
score: 0
Accepted
time: 0ms
memory: 8364kb
input:
1396 1581 367 468 21798364 829 830 9650179 485 486 16494843 933 934 8574488 289 290 27681659 480 481...
output:
8000000000
result:
ok answer is '8000000000'
Test #43:
score: 0
Accepted
time: 5ms
memory: 8356kb
input:
1180 1180 308 309 3246751 743 744 1345895 397 398 2518891 1029 1030 971816 27 28 37037036 158 159 63...
output:
1000000000
result:
ok answer is '1000000000'
Test #44:
score: 0
Accepted
time: 4ms
memory: 8356kb
input:
1271 1420 315 316 1000000000 934 935 1000000000 307 308 1000000000 535 536 1000000000 76 77 10000000...
output:
57000000000
result:
ok answer is '57000000000'
Test #45:
score: 0
Accepted
time: 4ms
memory: 8356kb
input:
1073 1429 734 735 647572083 51 681 419947902 272 273 837344549 512 928 331257693 722 723 989087978 1...
output:
20587879800
result:
ok answer is '20587879800'
Subtask #4:
score: 20
Accepted
Test #46:
score: 20
Accepted
time: 18ms
memory: 8940kb
input:
16112 16112 2214 2215 1000000000 5191 5192 1000000000 4736 4737 1000000000 9474 9475 1000000000 3823...
output:
12067000000000
result:
ok answer is '12067000000000'
Test #47:
score: 0
Accepted
time: 31ms
memory: 9868kb
input:
37831 42095 1982 1983 1000000000 36858 36859 1000000000 31643 31644 1000000000 8925 8926 1000000000 ...
output:
105000000000
result:
ok answer is '105000000000'
Test #48:
score: 0
Accepted
time: 28ms
memory: 9800kb
input:
30460 45141 16218 16219 1000000000 25583 25584 640425281 2613 2614 1000000000 9139 9140 1000000000 3...
output:
15599198861
result:
ok answer is '15599198861'
Test #49:
score: 0
Accepted
time: 23ms
memory: 8976kb
input:
17131 17131 12996 12997 1000000000 2685 2686 1000000000 11574 11575 1000000000 15747 15748 100000000...
output:
17130000000000
result:
ok answer is '17130000000000'
Test #50:
score: 0
Accepted
time: 34ms
memory: 9900kb
input:
32134 48342 3550 17156 43232692 21398 16021 119470119 12472 12473 339414987 2530 2531 684887772 2977...
output:
18937007240
result:
ok answer is '18937007240'
Test #51:
score: 0
Accepted
time: 32ms
memory: 9516kb
input:
11659 48524 1695 5756 1000000000 4014 602 1000000000 7052 184 1000000000 9308 980 1000000000 7232 96...
output:
7000000000
result:
ok answer is '7000000000'
Test #52:
score: 0
Accepted
time: 16ms
memory: 8932kb
input:
15885 15885 11450 11451 699469639 5491 5492 621647247 7796 7797 610827647 3178 3179 294255651 8564 8...
output:
12414959881712
result:
ok answer is '12414959881712'
Test #53:
score: 0
Accepted
time: 25ms
memory: 10148kb
input:
45116 48936 43378 43379 94425745 36469 36470 112314566 25614 25615 159912547 35266 35267 116145861 8...
output:
19065942000
result:
ok answer is '19065942000'
Test #54:
score: 0
Accepted
time: 29ms
memory: 10256kb
input:
49761 49852 37133 37134 247668354 8811 8812 355396990 26899 26900 555651875 46247 46248 247170285 12...
output:
1678107092765
result:
ok answer is '1678107092765'
Test #55:
score: 0
Accepted
time: 2ms
memory: 8392kb
input:
2103 2103 702 703 1000000000 1675 1676 1000000000 2018 2019 1000000000 1840 1841 1000000000 1305 130...
output:
2102000000000
result:
ok answer is '2102000000000'
Test #56:
score: 0
Accepted
time: 20ms
memory: 9692kb
input:
29379 41850 21135 17428 1000000000 25275 25276 1000000000 6511 9856 1000000000 27189 7894 1000000000...
output:
22000000000
result:
ok answer is '22000000000'
Test #57:
score: 0
Accepted
time: 35ms
memory: 9988kb
input:
41489 44551 1117 1118 482509016 7794 7795 703730792 20386 20387 983590194 26268 26269 134168214 1620...
output:
110862157400
result:
ok answer is '110862157400'
Test #58:
score: 0
Accepted
time: 12ms
memory: 8584kb
input:
7067 7067 4726 4727 1000000000 3064 3065 1000000000 3424 3425 1000000000 1911 1912 1000000000 2884 2...
output:
6179000000000
result:
ok answer is '6179000000000'
Test #59:
score: 0
Accepted
time: 19ms
memory: 9584kb
input:
31671 33468 21698 21699 1000000000 10487 10488 1000000000 7898 7899 1000000000 997 998 1000000000 16...
output:
128000000000
result:
ok answer is '128000000000'
Test #60:
score: 0
Accepted
time: 20ms
memory: 9096kb
input:
2493 30279 534 1951 537177381 1878 955 398472345 1222 536 144734396 18 742 691788334 2033 607 284713...
output:
898555380
result:
ok answer is '898555380'
Subtask #5:
score: 10
Accepted
Test #61:
score: 10
Accepted
time: 14ms
memory: 9056kb
input:
19248 19248 3945 3946 1000000000 5934 5935 1000000000 9729 9730 1000000000 11396 11397 1000000000 10...
output:
5017264818230
result:
ok answer is '5017264818230'
Test #62:
score: 0
Accepted
time: 612ms
memory: 17928kb
input:
207974 284660 41077 41078 519921917 34568 34569 808498172 144106 144107 16332219 150339 150340 18487...
output:
32419213125
result:
ok answer is '32419213125'
Test #63:
score: 0
Accepted
time: 221ms
memory: 16068kb
input:
186812 211360 19968 19969 50079 32964 32965 30335 103689 103690 9642 43457 43458 23009 22055 22056 4...
output:
1000000000
result:
ok answer is '1000000000'
Test #64:
score: 0
Accepted
time: 381ms
memory: 17016kb
input:
222934 222934 60683 60684 490030411 48332 48333 448237262 185982 185983 636132236 21645 21646 194927...
output:
221709980652438
result:
ok answer is '221709980652438'
Test #65:
score: 0
Accepted
time: 432ms
memory: 18424kb
input:
258610 259306 200792 200793 434662356 185227 185228 846610492 207591 207592 611739155 82768 82769 50...
output:
4430008560325
result:
ok answer is '4430008560325'
Test #66:
score: 0
Accepted
time: 36ms
memory: 11524kb
input:
68691 97295 52136 52137 1000000000 59302 59303 1000000000 61250 61251 1000000000 27218 27219 1000000...
output:
24000000000
result:
ok answer is '24000000000'
Test #67:
score: 0
Accepted
time: 98ms
memory: 10812kb
input:
64189 64189 35207 35208 393863317 20468 20469 666190416 44205 44206 459480213 54435 54436 628153716 ...
output:
64104145161728
result:
ok answer is '64104145161728'
Test #68:
score: 0
Accepted
time: 130ms
memory: 19724kb
input:
289638 296231 113164 113165 144241829 258986 258987 357262286 255442 255443 348855011 229380 229381 ...
output:
282719375197
result:
ok answer is '282719375197'
Test #69:
score: 0
Accepted
time: 131ms
memory: 16140kb
input:
191812 210251 70455 70456 3633523 138448 138449 1849067 122901 122902 2082976 7835 7836 32673898 190...
output:
5000000000
result:
ok answer is '5000000000'
Test #70:
score: 0
Accepted
time: 26ms
memory: 9360kb
input:
26976 26976 9830 9831 1627670 14683 14684 1089695 237 238 67510546 15319 15320 1044454 22165 22166 7...
output:
16000000000
result:
ok answer is '16000000000'
Test #71:
score: 0
Accepted
time: 1021ms
memory: 19016kb
input:
254742 294680 136106 116418 304908022 72842 72843 38586968 218009 218010 939575708 149064 149065 969...
output:
78075522269
result:
ok answer is '78075522269'
Test #72:
score: 0
Accepted
time: 299ms
memory: 18140kb
input:
220744 282814 149377 149378 107110 210569 12241 75982 71542 71543 223644 162292 162293 98586 8688 86...
output:
4000000000
result:
ok answer is '4000000000'
Test #73:
score: 0
Accepted
time: 115ms
memory: 11640kb
input:
85270 85270 13327 13328 880879153 34075 34076 980869479 62767 62768 478679185 70825 70826 199633166 ...
output:
72675847407345
result:
ok answer is '72675847407345'
Test #74:
score: 0
Accepted
time: 151ms
memory: 17808kb
input:
218677 272439 35162 35163 337550898 53357 53358 806436404 208293 36947 675107279 128708 128709 33906...
output:
25469097270
result:
ok answer is '25469097270'
Test #75:
score: 0
Accepted
time: 163ms
memory: 13708kb
input:
55879 185754 28025 42808 1000000000 18086 9871 1000000000 15408 17608 1000000000 54660 54661 1000000...
output:
9000000000
result:
ok answer is '9000000000'
Extra Test:
score: 0
Extra Test Passed