답안 #285012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
285012 2020-08-28T08:55:43 Z 3zp Aesthetic (NOI20_aesthetic) C++14
51 / 100
858 ms 67676 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<pair<ll, pair<ll, ll > > > v[300009];
vector<ll> T[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});
    }
}
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) continue;
        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});
            }
        }
    }
    vector<pair<ll,ll> > W;
    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.push_back({d1[i], i});
    }
    sort(W.begin(), W.end());
    for(ll i = 0; i < W.size(); i++){
        ll x = W[i].second;
        if(path[x]) wh[x] = x;
        else wh[x] = wh[par[x]];
        T[wh[x]].push_back(x);
    }
    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:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      |      ^
Aesthetic.cpp: In function 'int main()':
Aesthetic.cpp:84:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |     for(ll i = 0; i < W.size(); i++){
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 11 ms 14464 KB Output is correct
3 Correct 12 ms 14464 KB Output is correct
4 Correct 12 ms 14592 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 10 ms 14464 KB Output is correct
7 Correct 10 ms 14592 KB Output is correct
8 Correct 10 ms 14464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 11 ms 14464 KB Output is correct
3 Correct 12 ms 14464 KB Output is correct
4 Correct 12 ms 14592 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 10 ms 14464 KB Output is correct
7 Correct 10 ms 14592 KB Output is correct
8 Correct 10 ms 14464 KB Output is correct
9 Correct 12 ms 14848 KB Output is correct
10 Correct 11 ms 14848 KB Output is correct
11 Correct 12 ms 14848 KB Output is correct
12 Correct 13 ms 14848 KB Output is correct
13 Correct 13 ms 14720 KB Output is correct
14 Correct 12 ms 14752 KB Output is correct
15 Correct 14 ms 14848 KB Output is correct
16 Correct 12 ms 14720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 743 ms 65744 KB Output is correct
2 Correct 765 ms 65632 KB Output is correct
3 Correct 737 ms 64356 KB Output is correct
4 Correct 738 ms 65752 KB Output is correct
5 Correct 728 ms 64464 KB Output is correct
6 Correct 764 ms 66940 KB Output is correct
7 Correct 766 ms 66640 KB Output is correct
8 Correct 752 ms 65872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 785 ms 65628 KB Output is correct
2 Correct 773 ms 66148 KB Output is correct
3 Correct 780 ms 64848 KB Output is correct
4 Correct 781 ms 67536 KB Output is correct
5 Correct 748 ms 66268 KB Output is correct
6 Correct 794 ms 67664 KB Output is correct
7 Correct 793 ms 66108 KB Output is correct
8 Correct 762 ms 65564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 775 ms 60896 KB Output is correct
2 Correct 284 ms 61276 KB Output is correct
3 Correct 423 ms 53896 KB Output is correct
4 Correct 374 ms 52708 KB Output is correct
5 Correct 379 ms 52452 KB Output is correct
6 Correct 378 ms 53604 KB Output is correct
7 Correct 376 ms 52072 KB Output is correct
8 Correct 469 ms 52452 KB Output is correct
9 Correct 390 ms 51600 KB Output is correct
10 Correct 393 ms 54628 KB Output is correct
11 Correct 383 ms 52196 KB Output is correct
12 Correct 858 ms 61216 KB Output is correct
13 Correct 379 ms 52508 KB Output is correct
14 Correct 272 ms 67676 KB Output is correct
15 Correct 189 ms 60768 KB Output is correct
16 Correct 796 ms 62180 KB Output is correct
17 Correct 776 ms 59768 KB Output is correct
18 Correct 810 ms 61440 KB Output is correct
19 Correct 286 ms 61424 KB Output is correct
20 Correct 286 ms 61532 KB Output is correct
21 Correct 285 ms 61408 KB Output is correct
22 Correct 337 ms 61532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 775 ms 60896 KB Output is correct
2 Correct 284 ms 61276 KB Output is correct
3 Correct 423 ms 53896 KB Output is correct
4 Correct 374 ms 52708 KB Output is correct
5 Correct 379 ms 52452 KB Output is correct
6 Correct 378 ms 53604 KB Output is correct
7 Correct 376 ms 52072 KB Output is correct
8 Correct 469 ms 52452 KB Output is correct
9 Correct 390 ms 51600 KB Output is correct
10 Correct 393 ms 54628 KB Output is correct
11 Correct 383 ms 52196 KB Output is correct
12 Correct 858 ms 61216 KB Output is correct
13 Correct 379 ms 52508 KB Output is correct
14 Correct 272 ms 67676 KB Output is correct
15 Correct 189 ms 60768 KB Output is correct
16 Correct 796 ms 62180 KB Output is correct
17 Correct 776 ms 59768 KB Output is correct
18 Correct 810 ms 61440 KB Output is correct
19 Correct 286 ms 61424 KB Output is correct
20 Correct 286 ms 61532 KB Output is correct
21 Correct 285 ms 61408 KB Output is correct
22 Correct 337 ms 61532 KB Output is correct
23 Incorrect 650 ms 59740 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 11 ms 14464 KB Output is correct
3 Correct 12 ms 14464 KB Output is correct
4 Correct 12 ms 14592 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 10 ms 14464 KB Output is correct
7 Correct 10 ms 14592 KB Output is correct
8 Correct 10 ms 14464 KB Output is correct
9 Correct 12 ms 14848 KB Output is correct
10 Correct 11 ms 14848 KB Output is correct
11 Correct 12 ms 14848 KB Output is correct
12 Correct 13 ms 14848 KB Output is correct
13 Correct 13 ms 14720 KB Output is correct
14 Correct 12 ms 14752 KB Output is correct
15 Correct 14 ms 14848 KB Output is correct
16 Correct 12 ms 14720 KB Output is correct
17 Correct 743 ms 65744 KB Output is correct
18 Correct 765 ms 65632 KB Output is correct
19 Correct 737 ms 64356 KB Output is correct
20 Correct 738 ms 65752 KB Output is correct
21 Correct 728 ms 64464 KB Output is correct
22 Correct 764 ms 66940 KB Output is correct
23 Correct 766 ms 66640 KB Output is correct
24 Correct 752 ms 65872 KB Output is correct
25 Correct 785 ms 65628 KB Output is correct
26 Correct 773 ms 66148 KB Output is correct
27 Correct 780 ms 64848 KB Output is correct
28 Correct 781 ms 67536 KB Output is correct
29 Correct 748 ms 66268 KB Output is correct
30 Correct 794 ms 67664 KB Output is correct
31 Correct 793 ms 66108 KB Output is correct
32 Correct 762 ms 65564 KB Output is correct
33 Correct 775 ms 60896 KB Output is correct
34 Correct 284 ms 61276 KB Output is correct
35 Correct 423 ms 53896 KB Output is correct
36 Correct 374 ms 52708 KB Output is correct
37 Correct 379 ms 52452 KB Output is correct
38 Correct 378 ms 53604 KB Output is correct
39 Correct 376 ms 52072 KB Output is correct
40 Correct 469 ms 52452 KB Output is correct
41 Correct 390 ms 51600 KB Output is correct
42 Correct 393 ms 54628 KB Output is correct
43 Correct 383 ms 52196 KB Output is correct
44 Correct 858 ms 61216 KB Output is correct
45 Correct 379 ms 52508 KB Output is correct
46 Correct 272 ms 67676 KB Output is correct
47 Correct 189 ms 60768 KB Output is correct
48 Correct 796 ms 62180 KB Output is correct
49 Correct 776 ms 59768 KB Output is correct
50 Correct 810 ms 61440 KB Output is correct
51 Correct 286 ms 61424 KB Output is correct
52 Correct 286 ms 61532 KB Output is correct
53 Correct 285 ms 61408 KB Output is correct
54 Correct 337 ms 61532 KB Output is correct
55 Incorrect 650 ms 59740 KB Output isn't correct
56 Halted 0 ms 0 KB -