답안 #37940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37940 2017-12-29T11:57:20 Z 14kg 꿈 (IOI13_dreaming) C++11
47 / 100
102 ms 13664 KB
#include "dreaming.h"
#include <vector>
#include <algorithm>
#define N 100001
#define INF 2000000000

using namespace std;
int n, L, out, max_len, MAX[4], gd[N];
bool check[N], gd_check[N];
vector<pair<int,int> > r[N];

int max_f(int x, int y) { return x>y?x:y; }
int min_f(int x, int y) { return x<y?x:y; }

int g(int lev, int up_node){
    if(!gd_check[lev]){
        gd_check[lev]=true;
        for(vector<pair<int,int> >::iterator it=r[lev].begin(); it!=r[lev].end(); it++)
            if(it->first!=up_node) gd[lev]=max_f(gd[lev],it->second+g(it->first,lev));
    }
    return gd[lev];
}
void f(int lev, int up_len){
    int max1=0, max2=0, path, temp;

    check[lev]=true;
    for(vector<pair<int,int> >::iterator it=r[lev].begin(); it!=r[lev].end(); it++) {
        if(!check[it->first]) temp=g(it->first,lev)+it->second;
        else temp=up_len;

        if(max1<temp){
            max2=max1, max1=temp;
            path=it->first;
        }
        else if(max2<temp) max2=temp;
    }
    out=max_f(out,max1+max2);
    max_len=min_f(max_len,max1);

    for(vector<pair<int,int> >::iterator it=r[lev].begin(); it!=r[lev].end(); it++)
        if(!check[it->first]) f(it->first,(path==it->first?max2:max1)+it->second);
}

int travelTime(int _n, int m, int _L, int _a[], int _b[], int _t[]) {
    int x, y;

    n=_n, L=_L;
    for(int i=0; i<m; i++){
        x=_a[i]+1, y=_b[i]+1;
        r[x].push_back({y,_t[i]}), r[y].push_back({x,_t[i]});
    }

    for(int i=1; i<=n; i++)
        if(!check[i]){
            max_len=INF, f(i,0);

            MAX[0]=max_len, sort(MAX+0,MAX+4);
        }
    return max_f(out,max_f(MAX[3]+MAX[2]+L,MAX[1]?MAX[2]+MAX[1]+L+L:0));
}

Compilation message

dreaming.cpp: In function 'void f(int, int)':
dreaming.cpp:41:59: warning: 'path' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if(!check[it->first]) f(it->first,(path==it->first?max2:max1)+it->second);
                                           ~~~~~~~~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 10360 KB Output is correct
2 Correct 51 ms 9976 KB Output is correct
3 Correct 39 ms 8824 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 16 ms 3328 KB Output is correct
6 Correct 16 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 31 ms 5932 KB Output is correct
9 Correct 37 ms 7552 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 51 ms 8184 KB Output is correct
12 Correct 102 ms 9208 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 10360 KB Output is correct
2 Correct 51 ms 9976 KB Output is correct
3 Correct 39 ms 8824 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 16 ms 3328 KB Output is correct
6 Correct 16 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 31 ms 5932 KB Output is correct
9 Correct 37 ms 7552 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 51 ms 8184 KB Output is correct
12 Correct 102 ms 9208 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 4 ms 2816 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 3 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 3 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 3 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 10360 KB Output is correct
2 Correct 51 ms 9976 KB Output is correct
3 Correct 39 ms 8824 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 16 ms 3328 KB Output is correct
6 Correct 16 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 31 ms 5932 KB Output is correct
9 Correct 37 ms 7552 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 51 ms 8184 KB Output is correct
12 Correct 102 ms 9208 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 4 ms 2816 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 3 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 3 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 3 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 71 ms 10360 KB Output is correct
40 Correct 61 ms 9976 KB Output is correct
41 Correct 36 ms 8832 KB Output is correct
42 Correct 11 ms 3712 KB Output is correct
43 Correct 4 ms 2688 KB Output is correct
44 Correct 4 ms 2688 KB Output is correct
45 Correct 4 ms 2688 KB Output is correct
46 Correct 4 ms 2688 KB Output is correct
47 Correct 4 ms 2688 KB Output is correct
48 Correct 3 ms 2688 KB Output is correct
49 Correct 4 ms 2688 KB Output is correct
50 Correct 4 ms 2688 KB Output is correct
51 Correct 5 ms 2688 KB Output is correct
52 Correct 4 ms 2688 KB Output is correct
53 Correct 4 ms 2816 KB Output is correct
54 Correct 4 ms 2688 KB Output is correct
55 Correct 4 ms 2688 KB Output is correct
56 Correct 4 ms 2688 KB Output is correct
57 Correct 81 ms 8440 KB Output is correct
58 Correct 83 ms 8440 KB Output is correct
59 Correct 86 ms 8312 KB Output is correct
60 Correct 84 ms 8312 KB Output is correct
61 Correct 74 ms 8440 KB Output is correct
62 Correct 69 ms 8312 KB Output is correct
63 Correct 80 ms 8028 KB Output is correct
64 Correct 63 ms 8056 KB Output is correct
65 Correct 76 ms 8184 KB Output is correct
66 Correct 67 ms 8056 KB Output is correct
67 Correct 72 ms 8312 KB Output is correct
68 Correct 74 ms 8440 KB Output is correct
69 Correct 68 ms 8312 KB Output is correct
70 Correct 78 ms 8312 KB Output is correct
71 Correct 4 ms 2688 KB Output is correct
72 Correct 5 ms 2860 KB Output is correct
73 Correct 5 ms 2816 KB Output is correct
74 Correct 5 ms 2816 KB Output is correct
75 Correct 5 ms 2816 KB Output is correct
76 Correct 5 ms 2816 KB Output is correct
77 Correct 5 ms 2816 KB Output is correct
78 Correct 5 ms 2816 KB Output is correct
79 Correct 6 ms 2816 KB Output is correct
80 Correct 75 ms 8312 KB Output is correct
81 Correct 87 ms 8312 KB Output is correct
82 Correct 75 ms 8188 KB Output is correct
83 Correct 68 ms 8256 KB Output is correct
84 Correct 4 ms 2816 KB Output is correct
85 Correct 5 ms 2816 KB Output is correct
86 Correct 5 ms 2816 KB Output is correct
87 Correct 5 ms 2816 KB Output is correct
88 Correct 5 ms 2816 KB Output is correct
89 Correct 5 ms 2816 KB Output is correct
90 Correct 5 ms 2816 KB Output is correct
91 Correct 5 ms 2816 KB Output is correct
92 Correct 6 ms 2816 KB Output is correct
93 Correct 5 ms 2816 KB Output is correct
94 Correct 4 ms 2660 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 4 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 4 ms 2688 KB Output is correct
102 Correct 4 ms 2688 KB Output is correct
103 Correct 4 ms 2688 KB Output is correct
104 Correct 9 ms 3328 KB Output is correct
105 Correct 17 ms 4352 KB Output is correct
106 Correct 3 ms 2688 KB Output is correct
107 Correct 30 ms 5852 KB Output is correct
108 Correct 37 ms 7544 KB Output is correct
109 Correct 4 ms 2688 KB Output is correct
110 Correct 55 ms 8184 KB Output is correct
111 Correct 56 ms 9184 KB Output is correct
112 Correct 4 ms 2688 KB Output is correct
113 Correct 96 ms 13664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 5240 KB Output is correct
2 Correct 25 ms 5248 KB Output is correct
3 Correct 30 ms 5204 KB Output is correct
4 Correct 23 ms 5120 KB Output is correct
5 Correct 30 ms 5248 KB Output is correct
6 Correct 30 ms 5376 KB Output is correct
7 Correct 27 ms 5240 KB Output is correct
8 Correct 38 ms 5112 KB Output is correct
9 Correct 26 ms 5240 KB Output is correct
10 Correct 28 ms 5376 KB Output is correct
11 Correct 4 ms 2688 KB Output is correct
12 Correct 7 ms 2816 KB Output is correct
13 Correct 5 ms 2944 KB Output is correct
14 Correct 6 ms 2944 KB Output is correct
15 Correct 6 ms 2944 KB Output is correct
16 Correct 5 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 6 ms 2944 KB Output is correct
20 Incorrect 4 ms 2688 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 10360 KB Output is correct
2 Correct 51 ms 9976 KB Output is correct
3 Correct 39 ms 8824 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 16 ms 3328 KB Output is correct
6 Correct 16 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 31 ms 5932 KB Output is correct
9 Correct 37 ms 7552 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 51 ms 8184 KB Output is correct
12 Correct 102 ms 9208 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2816 KB Output is correct
16 Correct 5 ms 2816 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 5 ms 2816 KB Output is correct
19 Correct 5 ms 2816 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2816 KB Output is correct
22 Correct 5 ms 2816 KB Output is correct
23 Correct 3 ms 2688 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Correct 4 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 4 ms 2688 KB Output is correct
31 Correct 3 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 3 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 4 ms 2688 KB Output is correct
36 Correct 3 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 3 ms 2688 KB Output is correct
39 Correct 3 ms 2688 KB Output is correct
40 Incorrect 3 ms 2688 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 10360 KB Output is correct
2 Correct 51 ms 9976 KB Output is correct
3 Correct 39 ms 8824 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 16 ms 3328 KB Output is correct
6 Correct 16 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 31 ms 5932 KB Output is correct
9 Correct 37 ms 7552 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 51 ms 8184 KB Output is correct
12 Correct 102 ms 9208 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 4 ms 2816 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 3 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 3 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 3 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 71 ms 10360 KB Output is correct
40 Correct 61 ms 9976 KB Output is correct
41 Correct 36 ms 8832 KB Output is correct
42 Correct 11 ms 3712 KB Output is correct
43 Correct 4 ms 2688 KB Output is correct
44 Correct 4 ms 2688 KB Output is correct
45 Correct 4 ms 2688 KB Output is correct
46 Correct 4 ms 2688 KB Output is correct
47 Correct 4 ms 2688 KB Output is correct
48 Correct 3 ms 2688 KB Output is correct
49 Correct 4 ms 2688 KB Output is correct
50 Correct 4 ms 2688 KB Output is correct
51 Correct 5 ms 2688 KB Output is correct
52 Correct 4 ms 2688 KB Output is correct
53 Correct 4 ms 2816 KB Output is correct
54 Correct 4 ms 2688 KB Output is correct
55 Correct 4 ms 2688 KB Output is correct
56 Correct 4 ms 2688 KB Output is correct
57 Correct 81 ms 8440 KB Output is correct
58 Correct 83 ms 8440 KB Output is correct
59 Correct 86 ms 8312 KB Output is correct
60 Correct 84 ms 8312 KB Output is correct
61 Correct 74 ms 8440 KB Output is correct
62 Correct 69 ms 8312 KB Output is correct
63 Correct 80 ms 8028 KB Output is correct
64 Correct 63 ms 8056 KB Output is correct
65 Correct 76 ms 8184 KB Output is correct
66 Correct 67 ms 8056 KB Output is correct
67 Correct 72 ms 8312 KB Output is correct
68 Correct 74 ms 8440 KB Output is correct
69 Correct 68 ms 8312 KB Output is correct
70 Correct 78 ms 8312 KB Output is correct
71 Correct 4 ms 2688 KB Output is correct
72 Correct 5 ms 2860 KB Output is correct
73 Correct 5 ms 2816 KB Output is correct
74 Correct 5 ms 2816 KB Output is correct
75 Correct 5 ms 2816 KB Output is correct
76 Correct 5 ms 2816 KB Output is correct
77 Correct 5 ms 2816 KB Output is correct
78 Correct 5 ms 2816 KB Output is correct
79 Correct 6 ms 2816 KB Output is correct
80 Correct 75 ms 8312 KB Output is correct
81 Correct 87 ms 8312 KB Output is correct
82 Correct 75 ms 8188 KB Output is correct
83 Correct 68 ms 8256 KB Output is correct
84 Correct 4 ms 2816 KB Output is correct
85 Correct 5 ms 2816 KB Output is correct
86 Correct 5 ms 2816 KB Output is correct
87 Correct 5 ms 2816 KB Output is correct
88 Correct 5 ms 2816 KB Output is correct
89 Correct 5 ms 2816 KB Output is correct
90 Correct 5 ms 2816 KB Output is correct
91 Correct 5 ms 2816 KB Output is correct
92 Correct 6 ms 2816 KB Output is correct
93 Correct 5 ms 2816 KB Output is correct
94 Correct 4 ms 2660 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 4 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 4 ms 2688 KB Output is correct
102 Correct 4 ms 2688 KB Output is correct
103 Correct 4 ms 2688 KB Output is correct
104 Correct 9 ms 3328 KB Output is correct
105 Correct 17 ms 4352 KB Output is correct
106 Correct 3 ms 2688 KB Output is correct
107 Correct 30 ms 5852 KB Output is correct
108 Correct 37 ms 7544 KB Output is correct
109 Correct 4 ms 2688 KB Output is correct
110 Correct 55 ms 8184 KB Output is correct
111 Correct 56 ms 9184 KB Output is correct
112 Correct 4 ms 2688 KB Output is correct
113 Correct 96 ms 13664 KB Output is correct
114 Correct 22 ms 5240 KB Output is correct
115 Correct 25 ms 5248 KB Output is correct
116 Correct 30 ms 5204 KB Output is correct
117 Correct 23 ms 5120 KB Output is correct
118 Correct 30 ms 5248 KB Output is correct
119 Correct 30 ms 5376 KB Output is correct
120 Correct 27 ms 5240 KB Output is correct
121 Correct 38 ms 5112 KB Output is correct
122 Correct 26 ms 5240 KB Output is correct
123 Correct 28 ms 5376 KB Output is correct
124 Correct 4 ms 2688 KB Output is correct
125 Correct 7 ms 2816 KB Output is correct
126 Correct 5 ms 2944 KB Output is correct
127 Correct 6 ms 2944 KB Output is correct
128 Correct 6 ms 2944 KB Output is correct
129 Correct 5 ms 2816 KB Output is correct
130 Correct 5 ms 2816 KB Output is correct
131 Correct 6 ms 2944 KB Output is correct
132 Correct 6 ms 2944 KB Output is correct
133 Incorrect 4 ms 2688 KB Output isn't correct
134 Halted 0 ms 0 KB -