답안 #126875

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

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 76 ms 11760 KB Output is correct
2 Correct 71 ms 11760 KB Output is correct
3 Correct 47 ms 9196 KB Output is correct
4 Correct 14 ms 5104 KB Output is correct
5 Correct 12 ms 4592 KB Output is correct
6 Correct 21 ms 5744 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 35 ms 6640 KB Output is correct
9 Correct 44 ms 7920 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 63 ms 9200 KB Output is correct
12 Correct 69 ms 10356 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 11760 KB Output is correct
2 Correct 71 ms 11760 KB Output is correct
3 Correct 47 ms 9196 KB Output is correct
4 Correct 14 ms 5104 KB Output is correct
5 Correct 12 ms 4592 KB Output is correct
6 Correct 21 ms 5744 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 35 ms 6640 KB Output is correct
9 Correct 44 ms 7920 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 63 ms 9200 KB Output is correct
12 Correct 69 ms 10356 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 5 ms 3932 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 5 ms 3832 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 6 ms 3952 KB Output is correct
19 Correct 5 ms 3952 KB Output is correct
20 Correct 5 ms 3832 KB Output is correct
21 Correct 5 ms 3952 KB Output is correct
22 Correct 5 ms 3952 KB Output is correct
23 Correct 5 ms 3836 KB Output is correct
24 Correct 5 ms 3832 KB Output is correct
25 Correct 5 ms 3832 KB Output is correct
26 Correct 5 ms 3832 KB Output is correct
27 Correct 5 ms 3832 KB Output is correct
28 Correct 5 ms 3832 KB Output is correct
29 Correct 5 ms 3960 KB Output is correct
30 Correct 5 ms 3952 KB Output is correct
31 Correct 6 ms 3932 KB Output is correct
32 Correct 6 ms 3832 KB Output is correct
33 Correct 5 ms 3952 KB Output is correct
34 Correct 6 ms 3964 KB Output is correct
35 Correct 5 ms 3832 KB Output is correct
36 Correct 5 ms 3960 KB Output is correct
37 Correct 5 ms 3952 KB Output is correct
38 Correct 6 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 11760 KB Output is correct
2 Correct 71 ms 11760 KB Output is correct
3 Correct 47 ms 9196 KB Output is correct
4 Correct 14 ms 5104 KB Output is correct
5 Correct 12 ms 4592 KB Output is correct
6 Correct 21 ms 5744 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 35 ms 6640 KB Output is correct
9 Correct 44 ms 7920 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 63 ms 9200 KB Output is correct
12 Correct 69 ms 10356 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 5 ms 3932 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 5 ms 3832 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 6 ms 3952 KB Output is correct
19 Correct 5 ms 3952 KB Output is correct
20 Correct 5 ms 3832 KB Output is correct
21 Correct 5 ms 3952 KB Output is correct
22 Correct 5 ms 3952 KB Output is correct
23 Correct 5 ms 3836 KB Output is correct
24 Correct 5 ms 3832 KB Output is correct
25 Correct 5 ms 3832 KB Output is correct
26 Correct 5 ms 3832 KB Output is correct
27 Correct 5 ms 3832 KB Output is correct
28 Correct 5 ms 3832 KB Output is correct
29 Correct 5 ms 3960 KB Output is correct
30 Correct 5 ms 3952 KB Output is correct
31 Correct 6 ms 3932 KB Output is correct
32 Correct 6 ms 3832 KB Output is correct
33 Correct 5 ms 3952 KB Output is correct
34 Correct 6 ms 3964 KB Output is correct
35 Correct 5 ms 3832 KB Output is correct
36 Correct 5 ms 3960 KB Output is correct
37 Correct 5 ms 3952 KB Output is correct
38 Correct 6 ms 3960 KB Output is correct
39 Correct 69 ms 11736 KB Output is correct
40 Correct 74 ms 11708 KB Output is correct
41 Correct 46 ms 9200 KB Output is correct
42 Correct 14 ms 5104 KB Output is correct
43 Correct 5 ms 3832 KB Output is correct
44 Correct 5 ms 3960 KB Output is correct
45 Correct 5 ms 3832 KB Output is correct
46 Correct 5 ms 3960 KB Output is correct
47 Correct 5 ms 3960 KB Output is correct
48 Correct 5 ms 3960 KB Output is correct
49 Correct 5 ms 3832 KB Output is correct
50 Correct 5 ms 3952 KB Output is correct
51 Correct 5 ms 3832 KB Output is correct
52 Correct 5 ms 3836 KB Output is correct
53 Correct 5 ms 3856 KB Output is correct
54 Correct 5 ms 3952 KB Output is correct
55 Correct 5 ms 3960 KB Output is correct
56 Correct 5 ms 3832 KB Output is correct
57 Correct 84 ms 9080 KB Output is correct
58 Correct 81 ms 9076 KB Output is correct
59 Correct 92 ms 9200 KB Output is correct
60 Correct 89 ms 8944 KB Output is correct
61 Correct 87 ms 8952 KB Output is correct
62 Correct 92 ms 8976 KB Output is correct
63 Correct 76 ms 8800 KB Output is correct
64 Correct 80 ms 8824 KB Output is correct
65 Correct 77 ms 8824 KB Output is correct
66 Correct 76 ms 8824 KB Output is correct
67 Correct 83 ms 8940 KB Output is correct
68 Correct 79 ms 8952 KB Output is correct
69 Correct 90 ms 8972 KB Output is correct
70 Correct 90 ms 8944 KB Output is correct
71 Correct 5 ms 3832 KB Output is correct
72 Correct 7 ms 3960 KB Output is correct
73 Correct 7 ms 4076 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 3960 KB Output is correct
77 Correct 7 ms 4088 KB Output is correct
78 Correct 7 ms 4088 KB Output is correct
79 Correct 7 ms 4088 KB Output is correct
80 Correct 85 ms 8944 KB Output is correct
81 Correct 84 ms 8944 KB Output is correct
82 Correct 82 ms 8952 KB Output is correct
83 Correct 87 ms 8952 KB Output is correct
84 Correct 6 ms 4088 KB Output is correct
85 Correct 6 ms 3960 KB Output is correct
86 Correct 7 ms 3960 KB Output is correct
87 Correct 7 ms 4080 KB Output is correct
88 Correct 7 ms 3960 KB Output is correct
89 Correct 7 ms 3960 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 4088 KB Output is correct
93 Correct 7 ms 4088 KB Output is correct
94 Correct 5 ms 3832 KB Output is correct
95 Correct 5 ms 3832 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 3832 KB Output is correct
99 Correct 5 ms 3832 KB Output is correct
100 Correct 5 ms 3832 KB Output is correct
101 Correct 5 ms 3832 KB Output is correct
102 Correct 5 ms 3832 KB Output is correct
103 Correct 5 ms 3952 KB Output is correct
104 Correct 14 ms 4592 KB Output is correct
105 Correct 21 ms 5744 KB Output is correct
106 Correct 5 ms 3960 KB Output is correct
107 Correct 34 ms 6640 KB Output is correct
108 Correct 50 ms 7920 KB Output is correct
109 Correct 7 ms 3960 KB Output is correct
110 Correct 77 ms 9176 KB Output is correct
111 Correct 69 ms 10352 KB Output is correct
112 Correct 6 ms 3960 KB Output is correct
113 Correct 97 ms 12400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 6264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 11760 KB Output is correct
2 Correct 71 ms 11760 KB Output is correct
3 Correct 47 ms 9196 KB Output is correct
4 Correct 14 ms 5104 KB Output is correct
5 Correct 12 ms 4592 KB Output is correct
6 Correct 21 ms 5744 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 35 ms 6640 KB Output is correct
9 Correct 44 ms 7920 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 63 ms 9200 KB Output is correct
12 Correct 69 ms 10356 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 13 ms 3960 KB Output is correct
15 Correct 20 ms 3960 KB Output is correct
16 Correct 26 ms 4080 KB Output is correct
17 Correct 12 ms 3960 KB Output is correct
18 Correct 18 ms 3960 KB Output is correct
19 Correct 24 ms 4088 KB Output is correct
20 Correct 11 ms 3952 KB Output is correct
21 Correct 17 ms 3960 KB Output is correct
22 Correct 22 ms 3960 KB Output is correct
23 Correct 5 ms 3832 KB Output is correct
24 Correct 6 ms 3960 KB Output is correct
25 Correct 6 ms 3952 KB Output is correct
26 Correct 6 ms 3960 KB Output is correct
27 Correct 7 ms 3832 KB Output is correct
28 Correct 9 ms 3832 KB Output is correct
29 Correct 8 ms 3992 KB Output is correct
30 Correct 5 ms 3832 KB Output is correct
31 Correct 5 ms 3960 KB Output is correct
32 Correct 5 ms 3952 KB Output is correct
33 Correct 5 ms 3952 KB Output is correct
34 Correct 5 ms 3952 KB Output is correct
35 Correct 5 ms 3952 KB Output is correct
36 Correct 5 ms 3960 KB Output is correct
37 Correct 5 ms 3960 KB Output is correct
38 Correct 5 ms 3952 KB Output is correct
39 Correct 5 ms 3960 KB Output is correct
40 Correct 6 ms 3952 KB Output is correct
41 Correct 6 ms 3832 KB Output is correct
42 Correct 7 ms 4080 KB Output is correct
43 Correct 7 ms 4060 KB Output is correct
44 Correct 59 ms 3960 KB Output is correct
45 Correct 101 ms 3960 KB Output is correct
46 Correct 7 ms 3960 KB Output is correct
47 Correct 7 ms 4088 KB Output is correct
48 Correct 74 ms 3960 KB Output is correct
49 Correct 97 ms 3960 KB Output is correct
50 Correct 7 ms 3960 KB Output is correct
51 Correct 7 ms 4088 KB Output is correct
52 Correct 120 ms 3952 KB Output is correct
53 Correct 54 ms 4020 KB Output is correct
54 Correct 7 ms 4088 KB Output is correct
55 Correct 7 ms 3960 KB Output is correct
56 Correct 49 ms 3960 KB Output is correct
57 Correct 45 ms 3964 KB Output is correct
58 Correct 84 ms 3960 KB Output is correct
59 Correct 85 ms 3960 KB Output is correct
60 Correct 7 ms 3976 KB Output is correct
61 Correct 7 ms 4088 KB Output is correct
62 Correct 15 ms 4092 KB Output is correct
63 Correct 14 ms 3960 KB Output is correct
64 Correct 7 ms 4088 KB Output is correct
65 Correct 8 ms 4024 KB Output is correct
66 Correct 90 ms 3996 KB Output is correct
67 Correct 89 ms 3964 KB Output is correct
68 Correct 125 ms 3960 KB Output is correct
69 Correct 126 ms 3952 KB Output is correct
70 Correct 22 ms 4088 KB Output is correct
71 Correct 20 ms 4088 KB Output is correct
72 Correct 85 ms 3960 KB Output is correct
73 Correct 120 ms 3932 KB Output is correct
74 Correct 50 ms 3960 KB Output is correct
75 Correct 18 ms 3960 KB Output is correct
76 Correct 54 ms 3960 KB Output is correct
77 Correct 58 ms 3960 KB Output is correct
78 Correct 78 ms 3960 KB Output is correct
79 Correct 88 ms 3960 KB Output is correct
80 Correct 6 ms 3960 KB Output is correct
81 Correct 6 ms 4088 KB Output is correct
82 Correct 6 ms 3960 KB Output is correct
83 Correct 6 ms 3960 KB Output is correct
84 Correct 7 ms 4088 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 8 ms 4088 KB Output is correct
90 Correct 6 ms 3960 KB Output is correct
91 Correct 5 ms 3832 KB Output is correct
92 Correct 6 ms 3960 KB Output is correct
93 Correct 5 ms 3964 KB Output is correct
94 Correct 5 ms 3832 KB Output is correct
95 Correct 6 ms 3832 KB Output is correct
96 Correct 5 ms 3832 KB Output is correct
97 Correct 5 ms 3960 KB Output is correct
98 Correct 5 ms 3952 KB Output is correct
99 Correct 5 ms 3952 KB Output is correct
100 Correct 5 ms 3832 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 76 ms 11760 KB Output is correct
2 Correct 71 ms 11760 KB Output is correct
3 Correct 47 ms 9196 KB Output is correct
4 Correct 14 ms 5104 KB Output is correct
5 Correct 12 ms 4592 KB Output is correct
6 Correct 21 ms 5744 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 35 ms 6640 KB Output is correct
9 Correct 44 ms 7920 KB Output is correct
10 Correct 6 ms 3960 KB Output is correct
11 Correct 63 ms 9200 KB Output is correct
12 Correct 69 ms 10356 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 5 ms 3932 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 5 ms 3832 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 6 ms 3952 KB Output is correct
19 Correct 5 ms 3952 KB Output is correct
20 Correct 5 ms 3832 KB Output is correct
21 Correct 5 ms 3952 KB Output is correct
22 Correct 5 ms 3952 KB Output is correct
23 Correct 5 ms 3836 KB Output is correct
24 Correct 5 ms 3832 KB Output is correct
25 Correct 5 ms 3832 KB Output is correct
26 Correct 5 ms 3832 KB Output is correct
27 Correct 5 ms 3832 KB Output is correct
28 Correct 5 ms 3832 KB Output is correct
29 Correct 5 ms 3960 KB Output is correct
30 Correct 5 ms 3952 KB Output is correct
31 Correct 6 ms 3932 KB Output is correct
32 Correct 6 ms 3832 KB Output is correct
33 Correct 5 ms 3952 KB Output is correct
34 Correct 6 ms 3964 KB Output is correct
35 Correct 5 ms 3832 KB Output is correct
36 Correct 5 ms 3960 KB Output is correct
37 Correct 5 ms 3952 KB Output is correct
38 Correct 6 ms 3960 KB Output is correct
39 Correct 69 ms 11736 KB Output is correct
40 Correct 74 ms 11708 KB Output is correct
41 Correct 46 ms 9200 KB Output is correct
42 Correct 14 ms 5104 KB Output is correct
43 Correct 5 ms 3832 KB Output is correct
44 Correct 5 ms 3960 KB Output is correct
45 Correct 5 ms 3832 KB Output is correct
46 Correct 5 ms 3960 KB Output is correct
47 Correct 5 ms 3960 KB Output is correct
48 Correct 5 ms 3960 KB Output is correct
49 Correct 5 ms 3832 KB Output is correct
50 Correct 5 ms 3952 KB Output is correct
51 Correct 5 ms 3832 KB Output is correct
52 Correct 5 ms 3836 KB Output is correct
53 Correct 5 ms 3856 KB Output is correct
54 Correct 5 ms 3952 KB Output is correct
55 Correct 5 ms 3960 KB Output is correct
56 Correct 5 ms 3832 KB Output is correct
57 Correct 84 ms 9080 KB Output is correct
58 Correct 81 ms 9076 KB Output is correct
59 Correct 92 ms 9200 KB Output is correct
60 Correct 89 ms 8944 KB Output is correct
61 Correct 87 ms 8952 KB Output is correct
62 Correct 92 ms 8976 KB Output is correct
63 Correct 76 ms 8800 KB Output is correct
64 Correct 80 ms 8824 KB Output is correct
65 Correct 77 ms 8824 KB Output is correct
66 Correct 76 ms 8824 KB Output is correct
67 Correct 83 ms 8940 KB Output is correct
68 Correct 79 ms 8952 KB Output is correct
69 Correct 90 ms 8972 KB Output is correct
70 Correct 90 ms 8944 KB Output is correct
71 Correct 5 ms 3832 KB Output is correct
72 Correct 7 ms 3960 KB Output is correct
73 Correct 7 ms 4076 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 3960 KB Output is correct
77 Correct 7 ms 4088 KB Output is correct
78 Correct 7 ms 4088 KB Output is correct
79 Correct 7 ms 4088 KB Output is correct
80 Correct 85 ms 8944 KB Output is correct
81 Correct 84 ms 8944 KB Output is correct
82 Correct 82 ms 8952 KB Output is correct
83 Correct 87 ms 8952 KB Output is correct
84 Correct 6 ms 4088 KB Output is correct
85 Correct 6 ms 3960 KB Output is correct
86 Correct 7 ms 3960 KB Output is correct
87 Correct 7 ms 4080 KB Output is correct
88 Correct 7 ms 3960 KB Output is correct
89 Correct 7 ms 3960 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 4088 KB Output is correct
93 Correct 7 ms 4088 KB Output is correct
94 Correct 5 ms 3832 KB Output is correct
95 Correct 5 ms 3832 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 3832 KB Output is correct
99 Correct 5 ms 3832 KB Output is correct
100 Correct 5 ms 3832 KB Output is correct
101 Correct 5 ms 3832 KB Output is correct
102 Correct 5 ms 3832 KB Output is correct
103 Correct 5 ms 3952 KB Output is correct
104 Correct 14 ms 4592 KB Output is correct
105 Correct 21 ms 5744 KB Output is correct
106 Correct 5 ms 3960 KB Output is correct
107 Correct 34 ms 6640 KB Output is correct
108 Correct 50 ms 7920 KB Output is correct
109 Correct 7 ms 3960 KB Output is correct
110 Correct 77 ms 9176 KB Output is correct
111 Correct 69 ms 10352 KB Output is correct
112 Correct 6 ms 3960 KB Output is correct
113 Correct 97 ms 12400 KB Output is correct
114 Execution timed out 1084 ms 6264 KB Time limit exceeded
115 Halted 0 ms 0 KB -