답안 #126874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126874 2019-07-08T14:38:31 Z Bench0310 꿈 (IOI13_dreaming) C++17
59 / 100
1000 ms 18072 KB
#include <bits/stdc++.h>
#include "dreaming.h"

using namespace std;
const int N=100005;
const int inf=1000000000;

vector<pair<int,int>> v[N];
vector<bool> vis(N,0);
vector<int> diameter(N,0);
vector<int> center(N,0);
vector<int> path;

pair<int,int> get_last(int a)
{
    vector<int> dist(N,-1);
    dist[a]=0;
    queue<int> q;
    q.push(a);
    int last=a;
    while(!q.empty())
    {
        int e=q.front();
        q.pop();
        vis[e]=1;
        for(pair<int,int> p:v[e])
        {
            int to=p.first;
            if(dist[to]!=-1) continue;
            dist[to]=dist[e]+p.second;
            q.push(to);
            if(dist[to]>dist[last]) last=to;
        }
    }
    return make_pair(last,dist[last]);
}

bool get_path(int a,int p,int b)
{
    if(a==b) return 1;
    for(pair<int,int> temp:v[a])
    {
        int to=temp.first;
        if(to==p) continue;
        if(get_path(to,a,b))
        {
            path.push_back(temp.second);
            return 1;
        }
    }
    return 0;
}

void get_center(int a,int id)
{
    int one,two,len;
    tie(one,ignore)=get_last(a);
    tie(two,len)=get_last(one);
    diameter[id]=len;
    path.clear();
    get_path(one,-1,two);
    int best=diameter[id];
    int sum=0;
    for(int i=0;i<(int)path.size();i++)
    {
        sum+=path[i];
        best=min(best,max(sum,diameter[id]-sum));
    }
    center[id]=best;
}

int solve(int n,int l)
{
    int id=0;
    for(int i=0;i<n;i++) if(vis[i]==0) get_center(i,id++);
    int res=0;
    vector<pair<int,int>> root;
    for(int i=0;i<id;i++)
    {
        res=max(res,diameter[i]);
        root.push_back(make_pair(center[i],i));
    }
    sort(root.begin(),root.end(),greater<pair<int,int>>());
    if(id>1) res=max(res,root[0].first+l+root[1].first);
    if(id>2) res=max(res,root[1].first+2*l+root[2].first);
    return res;
}

int travelTime(int n,int m,int l,int a[],int b[],int t[])
{
    for(int i=0;i<m;i++)
    {
        v[a[i]].push_back(make_pair(b[i],t[i]));
        v[b[i]].push_back(make_pair(a[i],t[i]));
    }
    return solve(n,l);
}

/*int main()
{
    freopen("C:\\Users\\Benja\\Downloads\\ioi2013tests\\dreaming\\two-sticks-9.in","r",stdin);
    int n,m,l;
    scanf("%d%d%d",&n,&m,&l);
    for(int i=0;i<m;i++)
    {
        int a,b,t;
        scanf("%d%d%d",&a,&b,&t);
        v[a].push_back(make_pair(b,t));
        v[b].push_back(make_pair(a,t));
    }
    printf("%d\n",solve(n,l));
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 16368 KB Output is correct
2 Correct 73 ms 16624 KB Output is correct
3 Correct 50 ms 12528 KB Output is correct
4 Correct 14 ms 5872 KB Output is correct
5 Correct 13 ms 4848 KB Output is correct
6 Correct 21 ms 6896 KB Output is correct
7 Correct 6 ms 3952 KB Output is correct
8 Correct 35 ms 8176 KB Output is correct
9 Correct 46 ms 10228 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 62 ms 12272 KB Output is correct
12 Correct 74 ms 14192 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 16368 KB Output is correct
2 Correct 73 ms 16624 KB Output is correct
3 Correct 50 ms 12528 KB Output is correct
4 Correct 14 ms 5872 KB Output is correct
5 Correct 13 ms 4848 KB Output is correct
6 Correct 21 ms 6896 KB Output is correct
7 Correct 6 ms 3952 KB Output is correct
8 Correct 35 ms 8176 KB Output is correct
9 Correct 46 ms 10228 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 62 ms 12272 KB Output is correct
12 Correct 74 ms 14192 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 5 ms 3832 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 5 ms 3960 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 5 ms 3964 KB Output is correct
19 Correct 5 ms 3960 KB Output is correct
20 Correct 6 ms 3960 KB Output is correct
21 Correct 5 ms 3960 KB Output is correct
22 Correct 5 ms 3836 KB Output is correct
23 Correct 5 ms 3836 KB Output is correct
24 Correct 5 ms 3964 KB Output is correct
25 Correct 5 ms 3960 KB Output is correct
26 Correct 7 ms 3832 KB Output is correct
27 Correct 6 ms 3960 KB Output is correct
28 Correct 7 ms 3952 KB Output is correct
29 Correct 6 ms 3960 KB Output is correct
30 Correct 7 ms 3960 KB Output is correct
31 Correct 6 ms 3960 KB Output is correct
32 Correct 6 ms 3832 KB Output is correct
33 Correct 6 ms 3832 KB Output is correct
34 Correct 5 ms 3832 KB Output is correct
35 Correct 6 ms 3960 KB Output is correct
36 Correct 6 ms 3960 KB Output is correct
37 Correct 6 ms 3960 KB Output is correct
38 Correct 6 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 16368 KB Output is correct
2 Correct 73 ms 16624 KB Output is correct
3 Correct 50 ms 12528 KB Output is correct
4 Correct 14 ms 5872 KB Output is correct
5 Correct 13 ms 4848 KB Output is correct
6 Correct 21 ms 6896 KB Output is correct
7 Correct 6 ms 3952 KB Output is correct
8 Correct 35 ms 8176 KB Output is correct
9 Correct 46 ms 10228 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 62 ms 12272 KB Output is correct
12 Correct 74 ms 14192 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 5 ms 3832 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 5 ms 3960 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 5 ms 3964 KB Output is correct
19 Correct 5 ms 3960 KB Output is correct
20 Correct 6 ms 3960 KB Output is correct
21 Correct 5 ms 3960 KB Output is correct
22 Correct 5 ms 3836 KB Output is correct
23 Correct 5 ms 3836 KB Output is correct
24 Correct 5 ms 3964 KB Output is correct
25 Correct 5 ms 3960 KB Output is correct
26 Correct 7 ms 3832 KB Output is correct
27 Correct 6 ms 3960 KB Output is correct
28 Correct 7 ms 3952 KB Output is correct
29 Correct 6 ms 3960 KB Output is correct
30 Correct 7 ms 3960 KB Output is correct
31 Correct 6 ms 3960 KB Output is correct
32 Correct 6 ms 3832 KB Output is correct
33 Correct 6 ms 3832 KB Output is correct
34 Correct 5 ms 3832 KB Output is correct
35 Correct 6 ms 3960 KB Output is correct
36 Correct 6 ms 3960 KB Output is correct
37 Correct 6 ms 3960 KB Output is correct
38 Correct 6 ms 3832 KB Output is correct
39 Correct 76 ms 16644 KB Output is correct
40 Correct 77 ms 16624 KB Output is correct
41 Correct 50 ms 12656 KB Output is correct
42 Correct 17 ms 5848 KB Output is correct
43 Correct 6 ms 3832 KB Output is correct
44 Correct 5 ms 3832 KB Output is correct
45 Correct 6 ms 3836 KB Output is correct
46 Correct 6 ms 3960 KB Output is correct
47 Correct 7 ms 3960 KB Output is correct
48 Correct 6 ms 3832 KB Output is correct
49 Correct 6 ms 3832 KB Output is correct
50 Correct 5 ms 3964 KB Output is correct
51 Correct 6 ms 3952 KB Output is correct
52 Correct 6 ms 3832 KB Output is correct
53 Correct 6 ms 3832 KB Output is correct
54 Correct 6 ms 3960 KB Output is correct
55 Correct 5 ms 3832 KB Output is correct
56 Correct 6 ms 3832 KB Output is correct
57 Correct 99 ms 10484 KB Output is correct
58 Correct 85 ms 10432 KB Output is correct
59 Correct 76 ms 10352 KB Output is correct
60 Correct 84 ms 10344 KB Output is correct
61 Correct 81 ms 10360 KB Output is correct
62 Correct 83 ms 10488 KB Output is correct
63 Correct 71 ms 10104 KB Output is correct
64 Correct 73 ms 10104 KB Output is correct
65 Correct 73 ms 10360 KB Output is correct
66 Correct 74 ms 10360 KB Output is correct
67 Correct 78 ms 10352 KB Output is correct
68 Correct 82 ms 10328 KB Output is correct
69 Correct 89 ms 10704 KB Output is correct
70 Correct 82 ms 10580 KB Output is correct
71 Correct 5 ms 3832 KB Output is correct
72 Correct 7 ms 4088 KB Output is correct
73 Correct 7 ms 4088 KB Output is correct
74 Correct 7 ms 4088 KB Output is correct
75 Correct 7 ms 4088 KB Output is correct
76 Correct 7 ms 4088 KB Output is correct
77 Correct 7 ms 4092 KB Output is correct
78 Correct 7 ms 4088 KB Output is correct
79 Correct 7 ms 4088 KB Output is correct
80 Correct 80 ms 10260 KB Output is correct
81 Correct 81 ms 10352 KB Output is correct
82 Correct 76 ms 10480 KB Output is correct
83 Correct 79 ms 10360 KB Output is correct
84 Correct 7 ms 4088 KB Output is correct
85 Correct 6 ms 4088 KB Output is correct
86 Correct 7 ms 4088 KB Output is correct
87 Correct 7 ms 4088 KB Output is correct
88 Correct 7 ms 4088 KB Output is correct
89 Correct 6 ms 4080 KB Output is correct
90 Correct 7 ms 4080 KB Output is correct
91 Correct 7 ms 4088 KB Output is correct
92 Correct 7 ms 4048 KB Output is correct
93 Correct 7 ms 4088 KB Output is correct
94 Correct 5 ms 3960 KB Output is correct
95 Correct 6 ms 3880 KB Output is correct
96 Correct 5 ms 3960 KB Output is correct
97 Correct 6 ms 3832 KB Output is correct
98 Correct 5 ms 3960 KB Output is correct
99 Correct 6 ms 3952 KB Output is correct
100 Correct 6 ms 3960 KB Output is correct
101 Correct 5 ms 3832 KB Output is correct
102 Correct 5 ms 3932 KB Output is correct
103 Correct 5 ms 3832 KB Output is correct
104 Correct 13 ms 4848 KB Output is correct
105 Correct 21 ms 6896 KB Output is correct
106 Correct 6 ms 3960 KB Output is correct
107 Correct 36 ms 8176 KB Output is correct
108 Correct 46 ms 10224 KB Output is correct
109 Correct 6 ms 3964 KB Output is correct
110 Correct 62 ms 12116 KB Output is correct
111 Correct 72 ms 14192 KB Output is correct
112 Correct 6 ms 3960 KB Output is correct
113 Correct 98 ms 18072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 6648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 16368 KB Output is correct
2 Correct 73 ms 16624 KB Output is correct
3 Correct 50 ms 12528 KB Output is correct
4 Correct 14 ms 5872 KB Output is correct
5 Correct 13 ms 4848 KB Output is correct
6 Correct 21 ms 6896 KB Output is correct
7 Correct 6 ms 3952 KB Output is correct
8 Correct 35 ms 8176 KB Output is correct
9 Correct 46 ms 10228 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 62 ms 12272 KB Output is correct
12 Correct 74 ms 14192 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 25 ms 3960 KB Output is correct
15 Correct 41 ms 3960 KB Output is correct
16 Correct 60 ms 4092 KB Output is correct
17 Correct 24 ms 3960 KB Output is correct
18 Correct 37 ms 3960 KB Output is correct
19 Correct 52 ms 4088 KB Output is correct
20 Correct 19 ms 3960 KB Output is correct
21 Correct 33 ms 4084 KB Output is correct
22 Correct 54 ms 4096 KB Output is correct
23 Correct 6 ms 3952 KB Output is correct
24 Correct 7 ms 3836 KB Output is correct
25 Correct 6 ms 3952 KB Output is correct
26 Correct 6 ms 3832 KB Output is correct
27 Correct 6 ms 3960 KB Output is correct
28 Correct 16 ms 3960 KB Output is correct
29 Correct 13 ms 3832 KB Output is correct
30 Correct 6 ms 3952 KB Output is correct
31 Correct 7 ms 3920 KB Output is correct
32 Correct 6 ms 3876 KB Output is correct
33 Correct 5 ms 3960 KB Output is correct
34 Correct 5 ms 3960 KB Output is correct
35 Correct 6 ms 3960 KB Output is correct
36 Correct 5 ms 3960 KB Output is correct
37 Correct 5 ms 3960 KB Output is correct
38 Correct 6 ms 3832 KB Output is correct
39 Correct 5 ms 3952 KB Output is correct
40 Correct 5 ms 3832 KB Output is correct
41 Correct 5 ms 3836 KB Output is correct
42 Correct 7 ms 4336 KB Output is correct
43 Correct 7 ms 4336 KB Output is correct
44 Correct 143 ms 4080 KB Output is correct
45 Correct 255 ms 3960 KB Output is correct
46 Correct 7 ms 4088 KB Output is correct
47 Correct 7 ms 4088 KB Output is correct
48 Correct 186 ms 3960 KB Output is correct
49 Correct 240 ms 3960 KB Output is correct
50 Correct 8 ms 4088 KB Output is correct
51 Correct 7 ms 4088 KB Output is correct
52 Correct 297 ms 3952 KB Output is correct
53 Correct 133 ms 3960 KB Output is correct
54 Correct 7 ms 4088 KB Output is correct
55 Correct 7 ms 4088 KB Output is correct
56 Correct 118 ms 4088 KB Output is correct
57 Correct 106 ms 4088 KB Output is correct
58 Correct 212 ms 4080 KB Output is correct
59 Correct 213 ms 4076 KB Output is correct
60 Correct 7 ms 4088 KB Output is correct
61 Correct 7 ms 4088 KB Output is correct
62 Correct 28 ms 4088 KB Output is correct
63 Correct 23 ms 4088 KB Output is correct
64 Correct 7 ms 4088 KB Output is correct
65 Correct 7 ms 4088 KB Output is correct
66 Correct 213 ms 3960 KB Output is correct
67 Correct 216 ms 3960 KB Output is correct
68 Correct 301 ms 3836 KB Output is correct
69 Correct 319 ms 3960 KB Output is correct
70 Correct 44 ms 4088 KB Output is correct
71 Correct 40 ms 4088 KB Output is correct
72 Correct 211 ms 4080 KB Output is correct
73 Correct 288 ms 3832 KB Output is correct
74 Correct 124 ms 4080 KB Output is correct
75 Correct 38 ms 4088 KB Output is correct
76 Correct 124 ms 4080 KB Output is correct
77 Correct 139 ms 4080 KB Output is correct
78 Correct 194 ms 3960 KB Output is correct
79 Correct 209 ms 3960 KB Output is correct
80 Correct 7 ms 3960 KB Output is correct
81 Correct 7 ms 4088 KB Output is correct
82 Correct 7 ms 4088 KB Output is correct
83 Correct 7 ms 4088 KB Output is correct
84 Correct 7 ms 4080 KB Output is correct
85 Correct 7 ms 4088 KB Output is correct
86 Correct 7 ms 4080 KB Output is correct
87 Correct 7 ms 4088 KB Output is correct
88 Correct 7 ms 4088 KB Output is correct
89 Correct 7 ms 4080 KB Output is correct
90 Correct 5 ms 3960 KB Output is correct
91 Correct 5 ms 3832 KB Output is correct
92 Correct 5 ms 3964 KB Output is correct
93 Correct 5 ms 3952 KB Output is correct
94 Correct 5 ms 3948 KB Output is correct
95 Correct 5 ms 3960 KB Output is correct
96 Correct 5 ms 3960 KB Output is correct
97 Correct 5 ms 3832 KB Output is correct
98 Correct 5 ms 3908 KB Output is correct
99 Correct 5 ms 3960 KB Output is correct
100 Correct 6 ms 3952 KB Output is correct
101 Correct 6 ms 3956 KB Output is correct
102 Correct 6 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 16368 KB Output is correct
2 Correct 73 ms 16624 KB Output is correct
3 Correct 50 ms 12528 KB Output is correct
4 Correct 14 ms 5872 KB Output is correct
5 Correct 13 ms 4848 KB Output is correct
6 Correct 21 ms 6896 KB Output is correct
7 Correct 6 ms 3952 KB Output is correct
8 Correct 35 ms 8176 KB Output is correct
9 Correct 46 ms 10228 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 62 ms 12272 KB Output is correct
12 Correct 74 ms 14192 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 5 ms 3832 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 5 ms 3960 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 5 ms 3964 KB Output is correct
19 Correct 5 ms 3960 KB Output is correct
20 Correct 6 ms 3960 KB Output is correct
21 Correct 5 ms 3960 KB Output is correct
22 Correct 5 ms 3836 KB Output is correct
23 Correct 5 ms 3836 KB Output is correct
24 Correct 5 ms 3964 KB Output is correct
25 Correct 5 ms 3960 KB Output is correct
26 Correct 7 ms 3832 KB Output is correct
27 Correct 6 ms 3960 KB Output is correct
28 Correct 7 ms 3952 KB Output is correct
29 Correct 6 ms 3960 KB Output is correct
30 Correct 7 ms 3960 KB Output is correct
31 Correct 6 ms 3960 KB Output is correct
32 Correct 6 ms 3832 KB Output is correct
33 Correct 6 ms 3832 KB Output is correct
34 Correct 5 ms 3832 KB Output is correct
35 Correct 6 ms 3960 KB Output is correct
36 Correct 6 ms 3960 KB Output is correct
37 Correct 6 ms 3960 KB Output is correct
38 Correct 6 ms 3832 KB Output is correct
39 Correct 76 ms 16644 KB Output is correct
40 Correct 77 ms 16624 KB Output is correct
41 Correct 50 ms 12656 KB Output is correct
42 Correct 17 ms 5848 KB Output is correct
43 Correct 6 ms 3832 KB Output is correct
44 Correct 5 ms 3832 KB Output is correct
45 Correct 6 ms 3836 KB Output is correct
46 Correct 6 ms 3960 KB Output is correct
47 Correct 7 ms 3960 KB Output is correct
48 Correct 6 ms 3832 KB Output is correct
49 Correct 6 ms 3832 KB Output is correct
50 Correct 5 ms 3964 KB Output is correct
51 Correct 6 ms 3952 KB Output is correct
52 Correct 6 ms 3832 KB Output is correct
53 Correct 6 ms 3832 KB Output is correct
54 Correct 6 ms 3960 KB Output is correct
55 Correct 5 ms 3832 KB Output is correct
56 Correct 6 ms 3832 KB Output is correct
57 Correct 99 ms 10484 KB Output is correct
58 Correct 85 ms 10432 KB Output is correct
59 Correct 76 ms 10352 KB Output is correct
60 Correct 84 ms 10344 KB Output is correct
61 Correct 81 ms 10360 KB Output is correct
62 Correct 83 ms 10488 KB Output is correct
63 Correct 71 ms 10104 KB Output is correct
64 Correct 73 ms 10104 KB Output is correct
65 Correct 73 ms 10360 KB Output is correct
66 Correct 74 ms 10360 KB Output is correct
67 Correct 78 ms 10352 KB Output is correct
68 Correct 82 ms 10328 KB Output is correct
69 Correct 89 ms 10704 KB Output is correct
70 Correct 82 ms 10580 KB Output is correct
71 Correct 5 ms 3832 KB Output is correct
72 Correct 7 ms 4088 KB Output is correct
73 Correct 7 ms 4088 KB Output is correct
74 Correct 7 ms 4088 KB Output is correct
75 Correct 7 ms 4088 KB Output is correct
76 Correct 7 ms 4088 KB Output is correct
77 Correct 7 ms 4092 KB Output is correct
78 Correct 7 ms 4088 KB Output is correct
79 Correct 7 ms 4088 KB Output is correct
80 Correct 80 ms 10260 KB Output is correct
81 Correct 81 ms 10352 KB Output is correct
82 Correct 76 ms 10480 KB Output is correct
83 Correct 79 ms 10360 KB Output is correct
84 Correct 7 ms 4088 KB Output is correct
85 Correct 6 ms 4088 KB Output is correct
86 Correct 7 ms 4088 KB Output is correct
87 Correct 7 ms 4088 KB Output is correct
88 Correct 7 ms 4088 KB Output is correct
89 Correct 6 ms 4080 KB Output is correct
90 Correct 7 ms 4080 KB Output is correct
91 Correct 7 ms 4088 KB Output is correct
92 Correct 7 ms 4048 KB Output is correct
93 Correct 7 ms 4088 KB Output is correct
94 Correct 5 ms 3960 KB Output is correct
95 Correct 6 ms 3880 KB Output is correct
96 Correct 5 ms 3960 KB Output is correct
97 Correct 6 ms 3832 KB Output is correct
98 Correct 5 ms 3960 KB Output is correct
99 Correct 6 ms 3952 KB Output is correct
100 Correct 6 ms 3960 KB Output is correct
101 Correct 5 ms 3832 KB Output is correct
102 Correct 5 ms 3932 KB Output is correct
103 Correct 5 ms 3832 KB Output is correct
104 Correct 13 ms 4848 KB Output is correct
105 Correct 21 ms 6896 KB Output is correct
106 Correct 6 ms 3960 KB Output is correct
107 Correct 36 ms 8176 KB Output is correct
108 Correct 46 ms 10224 KB Output is correct
109 Correct 6 ms 3964 KB Output is correct
110 Correct 62 ms 12116 KB Output is correct
111 Correct 72 ms 14192 KB Output is correct
112 Correct 6 ms 3960 KB Output is correct
113 Correct 98 ms 18072 KB Output is correct
114 Execution timed out 1054 ms 6648 KB Time limit exceeded
115 Halted 0 ms 0 KB -