# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
285041 |
2020-08-28T09:20:13 Z |
3zp |
Aesthetic (NOI20_aesthetic) |
C++14 |
|
1089 ms |
90008 KB |
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<pair<ll, pair<ll, ll > > > v[300009];
vector<ll> T[300009],W[300009];
ll d1[300009],dn[300009], f[300009], g[300009],ea[300009],eb[300009],ec[300009], par[300009],path[300009],wh[300009];
multiset<pair<ll,ll> > S;
void ad(ll x){
g[x] = 1;
for(auto E : v[x]){
ll y = E.first, l = E.second.first, u= E.second.second;
auto it= S.find({dn[y] + l + d1[x], u});
if(g[y] == 1) S.erase(it);
if(g[y] == 0) S.insert({dn[x] + l + d1[y], u});
}
}
void dfs(int x, int p){
if(path[x]) wh[x] = x;
else wh[x] = wh[p];
T[wh[x]].push_back(x);
for(int y : W[x]){
dfs(y, x);
}
}
ll A = 0;
main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n, m;
cin >> n >> m;
for(ll i = 0; i < m; i++){
cin>>ea[i]>>eb[i]>>ec[i];
}
for(ll i = m-1; i >= 0; i--){
ll a = ea[i], b = eb[i], c = ec[i];
if(a != b){
v[a].push_back({b, {c,A}});
v[b].push_back({a, {c,A}});
}
A = max(A, c);
}
for(ll i = 1; i <= n; i++){
d1[i] = 1e18;
dn[i] = 1e18;
}
d1[1] = 0;
dn[n] = 0;
priority_queue<pair<ll, ll> > q;
q.push({0, 1});
while(q.size()){
ll x = q.top().second;
q.pop();
if(f[x]) continue;
f[x] = 1;
for(auto E: v[x]){
ll y = E.first, l = E.second.first;
if(!f[y] && d1[y] > d1[x] + l){
d1[y] = d1[x] + l;
par[y] = x;
q.push({-d1[y], y});
}
}
}
q.push({0, n});
for(ll i = 1; i <= n; i++)
f[i] = 0;
while(q.size()){
ll x = q.top().second;
q.pop();
if(f[x]) continue;
f[x] = 1;
for(auto E: v[x]){
ll y = E.first, l = E.second.first;
if(!f[y] && dn[y] > dn[x] + l){
dn[y] = dn[x] + l;
q.push({-dn[y], y});
}
}
}
ll ans = d1[n];
ll X = n;
while(1){
path[X] = 1;
if(X == 1) break;
X = par[X];
}
for(ll i = 1; i <= n; i++){
W[par[i]].push_back(i);
}
dfs(1,0);
ll x = n;
while(1){
for(ll y : T[x])
ad(y);
if(x == 1) break;
x = par[x];
if(S.size() == 0) continue;
ll U = S.begin()->first + S.begin()->second;
auto it = S.begin();
it++;
if(it != S.end()) U = min(U, it->first);
ans = max(ans, U);
}
cout<<ans<<endl;
}
Compilation message
Aesthetic.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
26 | main(){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
21504 KB |
Output is correct |
2 |
Correct |
15 ms |
21504 KB |
Output is correct |
3 |
Correct |
15 ms |
21504 KB |
Output is correct |
4 |
Correct |
15 ms |
21632 KB |
Output is correct |
5 |
Correct |
15 ms |
21504 KB |
Output is correct |
6 |
Correct |
16 ms |
21504 KB |
Output is correct |
7 |
Correct |
15 ms |
21504 KB |
Output is correct |
8 |
Correct |
17 ms |
21504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
21504 KB |
Output is correct |
2 |
Correct |
15 ms |
21504 KB |
Output is correct |
3 |
Correct |
15 ms |
21504 KB |
Output is correct |
4 |
Correct |
15 ms |
21632 KB |
Output is correct |
5 |
Correct |
15 ms |
21504 KB |
Output is correct |
6 |
Correct |
16 ms |
21504 KB |
Output is correct |
7 |
Correct |
15 ms |
21504 KB |
Output is correct |
8 |
Correct |
17 ms |
21504 KB |
Output is correct |
9 |
Correct |
26 ms |
21888 KB |
Output is correct |
10 |
Correct |
17 ms |
21888 KB |
Output is correct |
11 |
Correct |
23 ms |
21888 KB |
Output is correct |
12 |
Correct |
16 ms |
21888 KB |
Output is correct |
13 |
Correct |
17 ms |
21888 KB |
Output is correct |
14 |
Correct |
24 ms |
21880 KB |
Output is correct |
15 |
Correct |
17 ms |
21888 KB |
Output is correct |
16 |
Correct |
16 ms |
21888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
874 ms |
74028 KB |
Output is correct |
2 |
Correct |
808 ms |
74408 KB |
Output is correct |
3 |
Correct |
774 ms |
74348 KB |
Output is correct |
4 |
Correct |
802 ms |
74468 KB |
Output is correct |
5 |
Correct |
872 ms |
74732 KB |
Output is correct |
6 |
Correct |
886 ms |
76316 KB |
Output is correct |
7 |
Correct |
878 ms |
75564 KB |
Output is correct |
8 |
Correct |
901 ms |
76408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
866 ms |
75788 KB |
Output is correct |
2 |
Correct |
826 ms |
75240 KB |
Output is correct |
3 |
Correct |
880 ms |
73612 KB |
Output is correct |
4 |
Correct |
852 ms |
74128 KB |
Output is correct |
5 |
Correct |
875 ms |
75388 KB |
Output is correct |
6 |
Correct |
843 ms |
74352 KB |
Output is correct |
7 |
Correct |
872 ms |
74552 KB |
Output is correct |
8 |
Correct |
885 ms |
75668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
937 ms |
67556 KB |
Output is correct |
2 |
Correct |
308 ms |
72928 KB |
Output is correct |
3 |
Correct |
416 ms |
64236 KB |
Output is correct |
4 |
Correct |
493 ms |
64620 KB |
Output is correct |
5 |
Correct |
399 ms |
64232 KB |
Output is correct |
6 |
Correct |
476 ms |
64748 KB |
Output is correct |
7 |
Correct |
419 ms |
64496 KB |
Output is correct |
8 |
Correct |
432 ms |
64900 KB |
Output is correct |
9 |
Correct |
452 ms |
64364 KB |
Output is correct |
10 |
Correct |
425 ms |
64748 KB |
Output is correct |
11 |
Correct |
451 ms |
64240 KB |
Output is correct |
12 |
Correct |
910 ms |
69232 KB |
Output is correct |
13 |
Correct |
527 ms |
64624 KB |
Output is correct |
14 |
Correct |
316 ms |
84460 KB |
Output is correct |
15 |
Correct |
235 ms |
74232 KB |
Output is correct |
16 |
Correct |
962 ms |
69504 KB |
Output is correct |
17 |
Correct |
829 ms |
68132 KB |
Output is correct |
18 |
Correct |
833 ms |
68840 KB |
Output is correct |
19 |
Correct |
311 ms |
73080 KB |
Output is correct |
20 |
Correct |
306 ms |
73208 KB |
Output is correct |
21 |
Correct |
310 ms |
73208 KB |
Output is correct |
22 |
Correct |
385 ms |
73084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
937 ms |
67556 KB |
Output is correct |
2 |
Correct |
308 ms |
72928 KB |
Output is correct |
3 |
Correct |
416 ms |
64236 KB |
Output is correct |
4 |
Correct |
493 ms |
64620 KB |
Output is correct |
5 |
Correct |
399 ms |
64232 KB |
Output is correct |
6 |
Correct |
476 ms |
64748 KB |
Output is correct |
7 |
Correct |
419 ms |
64496 KB |
Output is correct |
8 |
Correct |
432 ms |
64900 KB |
Output is correct |
9 |
Correct |
452 ms |
64364 KB |
Output is correct |
10 |
Correct |
425 ms |
64748 KB |
Output is correct |
11 |
Correct |
451 ms |
64240 KB |
Output is correct |
12 |
Correct |
910 ms |
69232 KB |
Output is correct |
13 |
Correct |
527 ms |
64624 KB |
Output is correct |
14 |
Correct |
316 ms |
84460 KB |
Output is correct |
15 |
Correct |
235 ms |
74232 KB |
Output is correct |
16 |
Correct |
962 ms |
69504 KB |
Output is correct |
17 |
Correct |
829 ms |
68132 KB |
Output is correct |
18 |
Correct |
833 ms |
68840 KB |
Output is correct |
19 |
Correct |
311 ms |
73080 KB |
Output is correct |
20 |
Correct |
306 ms |
73208 KB |
Output is correct |
21 |
Correct |
310 ms |
73208 KB |
Output is correct |
22 |
Correct |
385 ms |
73084 KB |
Output is correct |
23 |
Correct |
879 ms |
69732 KB |
Output is correct |
24 |
Correct |
376 ms |
76024 KB |
Output is correct |
25 |
Correct |
514 ms |
63980 KB |
Output is correct |
26 |
Correct |
606 ms |
64812 KB |
Output is correct |
27 |
Correct |
490 ms |
64244 KB |
Output is correct |
28 |
Correct |
500 ms |
64916 KB |
Output is correct |
29 |
Correct |
486 ms |
63728 KB |
Output is correct |
30 |
Correct |
489 ms |
64768 KB |
Output is correct |
31 |
Correct |
470 ms |
64860 KB |
Output is correct |
32 |
Correct |
470 ms |
63536 KB |
Output is correct |
33 |
Correct |
557 ms |
64244 KB |
Output is correct |
34 |
Correct |
984 ms |
71784 KB |
Output is correct |
35 |
Correct |
490 ms |
63476 KB |
Output is correct |
36 |
Correct |
358 ms |
88600 KB |
Output is correct |
37 |
Correct |
445 ms |
89368 KB |
Output is correct |
38 |
Correct |
900 ms |
71656 KB |
Output is correct |
39 |
Correct |
919 ms |
71004 KB |
Output is correct |
40 |
Correct |
932 ms |
72420 KB |
Output is correct |
41 |
Correct |
457 ms |
75900 KB |
Output is correct |
42 |
Correct |
361 ms |
75768 KB |
Output is correct |
43 |
Correct |
364 ms |
75896 KB |
Output is correct |
44 |
Correct |
366 ms |
75772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
21504 KB |
Output is correct |
2 |
Correct |
15 ms |
21504 KB |
Output is correct |
3 |
Correct |
15 ms |
21504 KB |
Output is correct |
4 |
Correct |
15 ms |
21632 KB |
Output is correct |
5 |
Correct |
15 ms |
21504 KB |
Output is correct |
6 |
Correct |
16 ms |
21504 KB |
Output is correct |
7 |
Correct |
15 ms |
21504 KB |
Output is correct |
8 |
Correct |
17 ms |
21504 KB |
Output is correct |
9 |
Correct |
26 ms |
21888 KB |
Output is correct |
10 |
Correct |
17 ms |
21888 KB |
Output is correct |
11 |
Correct |
23 ms |
21888 KB |
Output is correct |
12 |
Correct |
16 ms |
21888 KB |
Output is correct |
13 |
Correct |
17 ms |
21888 KB |
Output is correct |
14 |
Correct |
24 ms |
21880 KB |
Output is correct |
15 |
Correct |
17 ms |
21888 KB |
Output is correct |
16 |
Correct |
16 ms |
21888 KB |
Output is correct |
17 |
Correct |
874 ms |
74028 KB |
Output is correct |
18 |
Correct |
808 ms |
74408 KB |
Output is correct |
19 |
Correct |
774 ms |
74348 KB |
Output is correct |
20 |
Correct |
802 ms |
74468 KB |
Output is correct |
21 |
Correct |
872 ms |
74732 KB |
Output is correct |
22 |
Correct |
886 ms |
76316 KB |
Output is correct |
23 |
Correct |
878 ms |
75564 KB |
Output is correct |
24 |
Correct |
901 ms |
76408 KB |
Output is correct |
25 |
Correct |
866 ms |
75788 KB |
Output is correct |
26 |
Correct |
826 ms |
75240 KB |
Output is correct |
27 |
Correct |
880 ms |
73612 KB |
Output is correct |
28 |
Correct |
852 ms |
74128 KB |
Output is correct |
29 |
Correct |
875 ms |
75388 KB |
Output is correct |
30 |
Correct |
843 ms |
74352 KB |
Output is correct |
31 |
Correct |
872 ms |
74552 KB |
Output is correct |
32 |
Correct |
885 ms |
75668 KB |
Output is correct |
33 |
Correct |
937 ms |
67556 KB |
Output is correct |
34 |
Correct |
308 ms |
72928 KB |
Output is correct |
35 |
Correct |
416 ms |
64236 KB |
Output is correct |
36 |
Correct |
493 ms |
64620 KB |
Output is correct |
37 |
Correct |
399 ms |
64232 KB |
Output is correct |
38 |
Correct |
476 ms |
64748 KB |
Output is correct |
39 |
Correct |
419 ms |
64496 KB |
Output is correct |
40 |
Correct |
432 ms |
64900 KB |
Output is correct |
41 |
Correct |
452 ms |
64364 KB |
Output is correct |
42 |
Correct |
425 ms |
64748 KB |
Output is correct |
43 |
Correct |
451 ms |
64240 KB |
Output is correct |
44 |
Correct |
910 ms |
69232 KB |
Output is correct |
45 |
Correct |
527 ms |
64624 KB |
Output is correct |
46 |
Correct |
316 ms |
84460 KB |
Output is correct |
47 |
Correct |
235 ms |
74232 KB |
Output is correct |
48 |
Correct |
962 ms |
69504 KB |
Output is correct |
49 |
Correct |
829 ms |
68132 KB |
Output is correct |
50 |
Correct |
833 ms |
68840 KB |
Output is correct |
51 |
Correct |
311 ms |
73080 KB |
Output is correct |
52 |
Correct |
306 ms |
73208 KB |
Output is correct |
53 |
Correct |
310 ms |
73208 KB |
Output is correct |
54 |
Correct |
385 ms |
73084 KB |
Output is correct |
55 |
Correct |
879 ms |
69732 KB |
Output is correct |
56 |
Correct |
376 ms |
76024 KB |
Output is correct |
57 |
Correct |
514 ms |
63980 KB |
Output is correct |
58 |
Correct |
606 ms |
64812 KB |
Output is correct |
59 |
Correct |
490 ms |
64244 KB |
Output is correct |
60 |
Correct |
500 ms |
64916 KB |
Output is correct |
61 |
Correct |
486 ms |
63728 KB |
Output is correct |
62 |
Correct |
489 ms |
64768 KB |
Output is correct |
63 |
Correct |
470 ms |
64860 KB |
Output is correct |
64 |
Correct |
470 ms |
63536 KB |
Output is correct |
65 |
Correct |
557 ms |
64244 KB |
Output is correct |
66 |
Correct |
984 ms |
71784 KB |
Output is correct |
67 |
Correct |
490 ms |
63476 KB |
Output is correct |
68 |
Correct |
358 ms |
88600 KB |
Output is correct |
69 |
Correct |
445 ms |
89368 KB |
Output is correct |
70 |
Correct |
900 ms |
71656 KB |
Output is correct |
71 |
Correct |
919 ms |
71004 KB |
Output is correct |
72 |
Correct |
932 ms |
72420 KB |
Output is correct |
73 |
Correct |
457 ms |
75900 KB |
Output is correct |
74 |
Correct |
361 ms |
75768 KB |
Output is correct |
75 |
Correct |
364 ms |
75896 KB |
Output is correct |
76 |
Correct |
366 ms |
75772 KB |
Output is correct |
77 |
Correct |
1089 ms |
74980 KB |
Output is correct |
78 |
Correct |
512 ms |
78072 KB |
Output is correct |
79 |
Correct |
727 ms |
66292 KB |
Output is correct |
80 |
Correct |
570 ms |
65060 KB |
Output is correct |
81 |
Correct |
638 ms |
66812 KB |
Output is correct |
82 |
Correct |
653 ms |
66068 KB |
Output is correct |
83 |
Correct |
596 ms |
65652 KB |
Output is correct |
84 |
Correct |
647 ms |
65876 KB |
Output is correct |
85 |
Correct |
649 ms |
67444 KB |
Output is correct |
86 |
Correct |
727 ms |
66360 KB |
Output is correct |
87 |
Correct |
784 ms |
66032 KB |
Output is correct |
88 |
Correct |
950 ms |
74216 KB |
Output is correct |
89 |
Correct |
594 ms |
66676 KB |
Output is correct |
90 |
Correct |
303 ms |
89308 KB |
Output is correct |
91 |
Correct |
355 ms |
90008 KB |
Output is correct |
92 |
Correct |
1053 ms |
74856 KB |
Output is correct |
93 |
Correct |
914 ms |
74016 KB |
Output is correct |
94 |
Correct |
1008 ms |
73188 KB |
Output is correct |
95 |
Correct |
381 ms |
78200 KB |
Output is correct |
96 |
Correct |
382 ms |
78072 KB |
Output is correct |
97 |
Correct |
379 ms |
78136 KB |
Output is correct |
98 |
Correct |
383 ms |
77944 KB |
Output is correct |