답안 #441287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441287 2021-07-04T20:51:07 Z julian33 꿈 (IOI13_dreaming) C++14
47 / 100
113 ms 16792 KB
#include <bits/stdc++.h>
#include "dreaming.h"

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}

const int mxN=1e5+5;

vector<pii> graph[mxN];
ll dist[mxN],r=2e9;
int ep,seen[mxN],good[mxN],st;
vector<int> path;

void dfs(int at,int p){
    path.pb(dist[at]);
    seen[at]=1;
    if(dist[at]>dist[ep])
        ep=at;
    for(pii &i:graph[at]){
        if(i.first!=p){
            dist[i.first]=dist[at]+i.second;
            dfs(i.first,at);
        }
    }
}

void get_rad(int at,int p){
    if(at==ep)
        good[at]=1;
    for(pii &i:graph[at]){
        if(i.first==p)
            continue;
        get_rad(i.first,at);
        good[at]|=good[i.first];
    }
    if(good[at]){
        mina(r,max(dist[at],dist[ep]-dist[at]));
    }
}

void merge(pii &a,pii &b,int L){
    if(max(a.first,b.first)>a.second+b.second+L){
        if(a.first<b.first)
            swap(a,b);
    } else if(max(a.first,b.first)<a.second+b.second+L){
        int k=a.second+b.second+L;
        a.second=min(max(a.second,k-a.second),max(b.second,k-b.second));
        a.first=k;
    } else{
        int k=a.first<b.first?b.second:a.second;
        a.second=min(min(max(a.second,k-a.second),max(b.second,k-b.second)),k);
        a.first=max(a.first,b.first);
    }
}

int travelTime(int N,int M,int L,int A[],int B[],int T[]){
    for(int i=0;i<M;i++){
        graph[A[i]].pb({B[i],T[i]});
        graph[B[i]].pb({A[i],T[i]});
    }
    vector<pii> all;
    for(int i=0;i<N;i++){
        if(seen[i])
            continue;
        ep=N;
        dfs(i,-1);
        path.clear();
        dist[ep]=0; st=ep;
        dfs(ep,-1);
        r=2e9;
        get_rad(st,-1);
        all.pb({dist[ep],r});
        path.clear();
    }
    pii ans=all[0];
    for(int i=1;i<sz(all);i++){
        merge(ans,all[i],L);
    }
    return ans.first;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 15556 KB Output is correct
2 Correct 56 ms 15524 KB Output is correct
3 Correct 36 ms 11140 KB Output is correct
4 Correct 8 ms 4556 KB Output is correct
5 Correct 7 ms 3660 KB Output is correct
6 Correct 14 ms 5580 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 25 ms 7044 KB Output is correct
9 Correct 46 ms 8900 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 62 ms 10740 KB Output is correct
12 Correct 68 ms 13128 KB Output is correct
13 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2660 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2628 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 3 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 15556 KB Output is correct
2 Correct 56 ms 15524 KB Output is correct
3 Correct 36 ms 11140 KB Output is correct
4 Correct 8 ms 4556 KB Output is correct
5 Correct 7 ms 3660 KB Output is correct
6 Correct 14 ms 5580 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 25 ms 7044 KB Output is correct
9 Correct 46 ms 8900 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 62 ms 10740 KB Output is correct
12 Correct 68 ms 13128 KB Output is correct
13 Correct 2 ms 2764 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2660 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2628 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 3 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 2636 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2636 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Correct 2 ms 2636 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 58 ms 15528 KB Output is correct
40 Correct 80 ms 15524 KB Output is correct
41 Correct 37 ms 11072 KB Output is correct
42 Correct 8 ms 4584 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2636 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2636 KB Output is correct
51 Correct 2 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2636 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 104 ms 9864 KB Output is correct
58 Correct 82 ms 9648 KB Output is correct
59 Correct 95 ms 9724 KB Output is correct
60 Correct 102 ms 9584 KB Output is correct
61 Correct 113 ms 9608 KB Output is correct
62 Correct 76 ms 9540 KB Output is correct
63 Correct 83 ms 9504 KB Output is correct
64 Correct 69 ms 9464 KB Output is correct
65 Correct 76 ms 9516 KB Output is correct
66 Correct 87 ms 9456 KB Output is correct
67 Correct 93 ms 9684 KB Output is correct
68 Correct 83 ms 9836 KB Output is correct
69 Correct 80 ms 9608 KB Output is correct
70 Correct 77 ms 9660 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 3 ms 2788 KB Output is correct
73 Correct 3 ms 2892 KB Output is correct
74 Correct 3 ms 2892 KB Output is correct
75 Correct 3 ms 2764 KB Output is correct
76 Correct 3 ms 2892 KB Output is correct
77 Correct 3 ms 2892 KB Output is correct
78 Correct 3 ms 2764 KB Output is correct
79 Correct 4 ms 2892 KB Output is correct
80 Correct 83 ms 9840 KB Output is correct
81 Correct 91 ms 9612 KB Output is correct
82 Correct 82 ms 9552 KB Output is correct
83 Correct 91 ms 9636 KB Output is correct
84 Correct 3 ms 2764 KB Output is correct
85 Correct 3 ms 2764 KB Output is correct
86 Correct 3 ms 2764 KB Output is correct
87 Correct 3 ms 2764 KB Output is correct
88 Correct 3 ms 2764 KB Output is correct
89 Correct 3 ms 2764 KB Output is correct
90 Correct 3 ms 2764 KB Output is correct
91 Correct 3 ms 2764 KB Output is correct
92 Correct 4 ms 2892 KB Output is correct
93 Correct 3 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 2 ms 2636 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2560 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 7 ms 3660 KB Output is correct
105 Correct 14 ms 5580 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 28 ms 7008 KB Output is correct
108 Correct 36 ms 9012 KB Output is correct
109 Correct 2 ms 2636 KB Output is correct
110 Correct 70 ms 11008 KB Output is correct
111 Correct 68 ms 13136 KB Output is correct
112 Correct 2 ms 2764 KB Output is correct
113 Correct 98 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 7052 KB Output is correct
2 Incorrect 28 ms 7028 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2660 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2628 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 3 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 3 ms 2764 KB Output is correct
28 Correct 3 ms 2764 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 3 ms 2892 KB Output is correct
31 Correct 3 ms 2764 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Incorrect 3 ms 2764 KB Output isn't correct
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 15556 KB Output is correct
2 Correct 56 ms 15524 KB Output is correct
3 Correct 36 ms 11140 KB Output is correct
4 Correct 8 ms 4556 KB Output is correct
5 Correct 7 ms 3660 KB Output is correct
6 Correct 14 ms 5580 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 25 ms 7044 KB Output is correct
9 Correct 46 ms 8900 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 62 ms 10740 KB Output is correct
12 Correct 68 ms 13128 KB Output is correct
13 Correct 2 ms 2764 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2660 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2628 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 3 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 2636 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2636 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Correct 2 ms 2636 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 58 ms 15528 KB Output is correct
40 Correct 80 ms 15524 KB Output is correct
41 Correct 37 ms 11072 KB Output is correct
42 Correct 8 ms 4584 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2636 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2636 KB Output is correct
51 Correct 2 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2636 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 104 ms 9864 KB Output is correct
58 Correct 82 ms 9648 KB Output is correct
59 Correct 95 ms 9724 KB Output is correct
60 Correct 102 ms 9584 KB Output is correct
61 Correct 113 ms 9608 KB Output is correct
62 Correct 76 ms 9540 KB Output is correct
63 Correct 83 ms 9504 KB Output is correct
64 Correct 69 ms 9464 KB Output is correct
65 Correct 76 ms 9516 KB Output is correct
66 Correct 87 ms 9456 KB Output is correct
67 Correct 93 ms 9684 KB Output is correct
68 Correct 83 ms 9836 KB Output is correct
69 Correct 80 ms 9608 KB Output is correct
70 Correct 77 ms 9660 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 3 ms 2788 KB Output is correct
73 Correct 3 ms 2892 KB Output is correct
74 Correct 3 ms 2892 KB Output is correct
75 Correct 3 ms 2764 KB Output is correct
76 Correct 3 ms 2892 KB Output is correct
77 Correct 3 ms 2892 KB Output is correct
78 Correct 3 ms 2764 KB Output is correct
79 Correct 4 ms 2892 KB Output is correct
80 Correct 83 ms 9840 KB Output is correct
81 Correct 91 ms 9612 KB Output is correct
82 Correct 82 ms 9552 KB Output is correct
83 Correct 91 ms 9636 KB Output is correct
84 Correct 3 ms 2764 KB Output is correct
85 Correct 3 ms 2764 KB Output is correct
86 Correct 3 ms 2764 KB Output is correct
87 Correct 3 ms 2764 KB Output is correct
88 Correct 3 ms 2764 KB Output is correct
89 Correct 3 ms 2764 KB Output is correct
90 Correct 3 ms 2764 KB Output is correct
91 Correct 3 ms 2764 KB Output is correct
92 Correct 4 ms 2892 KB Output is correct
93 Correct 3 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 2 ms 2636 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2560 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 7 ms 3660 KB Output is correct
105 Correct 14 ms 5580 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 28 ms 7008 KB Output is correct
108 Correct 36 ms 9012 KB Output is correct
109 Correct 2 ms 2636 KB Output is correct
110 Correct 70 ms 11008 KB Output is correct
111 Correct 68 ms 13136 KB Output is correct
112 Correct 2 ms 2764 KB Output is correct
113 Correct 98 ms 16792 KB Output is correct
114 Correct 25 ms 7052 KB Output is correct
115 Incorrect 28 ms 7028 KB Output isn't correct
116 Halted 0 ms 0 KB -