답안 #104477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104477 2019-04-07T01:23:46 Z CaroLinda 꿈 (IOI13_dreaming) C++14
47 / 100
1000 ms 12912 KB
#include <bits/stdc++.h>
#include "dreaming.h"

#define MAXN 100005
#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
#define max3(a,b,c) max(max(a,b),c)


using namespace std;

//declarations
int N , M , L;
int radio1, radio2 ;

int d[MAXN] , dX[MAXN] , p[MAXN];

bool marc[MAXN] ;

vector<int> radios ;
vector<pii> adj[MAXN] ;

//utilities

void atribution()
{ lp(i,0,N) dX[i] = d[i] ; }

void ini(int x)
{ memset(d , -1 , sizeof d) ; d[x] = 0 ;}

void dfs(int x)
{
    marc[x] = 1 ;
    lp(i , 0 , adj[x].size() )
    {
        int v = adj[x][i].ff ;
        if(d[v] != -1) continue ;
        d[v] = d[x] + adj[x][i].ss ;
        p[v] = x ;
        dfs(v) ;
    }
}

int findMax()
{ return max_element(d, d+N) - d ; }

int findRadio(int diam , int x)
{
    int ans = diam ;
    for(int i = x ; i != -1 ; i = p[i])
          ans = min( ans , max(d[i] , diam - d[i]) ) ;
    return ans ;
}


int travelTime( int n , int m , int l , int A[] , int B[] , int T[] )
{
    N = n , M = m , L = l;
    int ans = 0 ;

    vector<int> edge ;

    lp(i,0,M)
    {
        int a = A[i] , b = B[i] ;
        adj[a].pb( pii(b, T[i]) ) ;
        adj[b].pb( pii(a, T[i]) ) ;
        edge.pb(T[i]) ;
    }


    lp(i,0,N)
        if(!marc[i])
        {
            ini(i) ; dfs(i) ;
            int X = findMax() ;
            ini(X) ; dfs(X) ;
            int Y = findMax() ;
            p[X] = -1 ;
            int k = findRadio(d[Y] , Y) ;
            radios.pb(k) ;
            ans = max(ans, d[Y]) ;
            //printf("%d %d %d\n", X, Y, k) ;
        }

    sort(radios.begin() , radios.end()) ;
    reverse(radios.begin() , radios.end() ) ;

    ans = max( ans , radios[0] + radios[1] + L ) ;

    if(radios.size() == 2) return ans ;

    ans = max( ans , radios[1] + radios[2] + 2*L ) ;

    return ans ;


}

/*int main()
{
    int n , m , l , a[MAXN] , b[MAXN] , t[MAXN] ;
    scanf("%d %d %d", &n, &m, &l) ;
    lp(i,0,m) scanf("%d%d%d", &a[i] , &b[i] , &t[i]) ;
    printf("%d\n",travelTime(n,m,l,a,b,t)) ;
}*/

Compilation message

dreaming.cpp: In function 'void dfs(int)':
dreaming.cpp:5:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define lp(i,a,b) for(int i = a ; i < b ; i++)
dreaming.cpp:37:8:
     lp(i , 0 , adj[x].size() )
        ~~~~~~~~~~~~~~~~~~~~~         
dreaming.cpp:37:5: note: in expansion of macro 'lp'
     lp(i , 0 , adj[x].size() )
     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 12016 KB Output is correct
2 Correct 69 ms 12140 KB Output is correct
3 Correct 48 ms 8948 KB Output is correct
4 Correct 11 ms 4480 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 17 ms 5120 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 37 ms 6260 KB Output is correct
9 Correct 41 ms 7540 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 63 ms 8944 KB Output is correct
12 Correct 79 ms 10464 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 12016 KB Output is correct
2 Correct 69 ms 12140 KB Output is correct
3 Correct 48 ms 8948 KB Output is correct
4 Correct 11 ms 4480 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 17 ms 5120 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 37 ms 6260 KB Output is correct
9 Correct 41 ms 7540 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 63 ms 8944 KB Output is correct
12 Correct 79 ms 10464 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 5 ms 3072 KB Output is correct
16 Correct 4 ms 3072 KB Output is correct
17 Correct 4 ms 3072 KB Output is correct
18 Correct 4 ms 3072 KB Output is correct
19 Correct 4 ms 3072 KB Output is correct
20 Correct 4 ms 3072 KB Output is correct
21 Correct 4 ms 3072 KB Output is correct
22 Correct 4 ms 3072 KB Output is correct
23 Correct 4 ms 3072 KB Output is correct
24 Correct 4 ms 3072 KB Output is correct
25 Correct 4 ms 3072 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 4 ms 3072 KB Output is correct
28 Correct 4 ms 3072 KB Output is correct
29 Correct 4 ms 3072 KB Output is correct
30 Correct 4 ms 3072 KB Output is correct
31 Correct 5 ms 3072 KB Output is correct
32 Correct 4 ms 3072 KB Output is correct
33 Correct 4 ms 3072 KB Output is correct
34 Correct 4 ms 3072 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 12016 KB Output is correct
2 Correct 69 ms 12140 KB Output is correct
3 Correct 48 ms 8948 KB Output is correct
4 Correct 11 ms 4480 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 17 ms 5120 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 37 ms 6260 KB Output is correct
9 Correct 41 ms 7540 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 63 ms 8944 KB Output is correct
12 Correct 79 ms 10464 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 5 ms 3072 KB Output is correct
16 Correct 4 ms 3072 KB Output is correct
17 Correct 4 ms 3072 KB Output is correct
18 Correct 4 ms 3072 KB Output is correct
19 Correct 4 ms 3072 KB Output is correct
20 Correct 4 ms 3072 KB Output is correct
21 Correct 4 ms 3072 KB Output is correct
22 Correct 4 ms 3072 KB Output is correct
23 Correct 4 ms 3072 KB Output is correct
24 Correct 4 ms 3072 KB Output is correct
25 Correct 4 ms 3072 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 4 ms 3072 KB Output is correct
28 Correct 4 ms 3072 KB Output is correct
29 Correct 4 ms 3072 KB Output is correct
30 Correct 4 ms 3072 KB Output is correct
31 Correct 5 ms 3072 KB Output is correct
32 Correct 4 ms 3072 KB Output is correct
33 Correct 4 ms 3072 KB Output is correct
34 Correct 4 ms 3072 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 3072 KB Output is correct
39 Correct 63 ms 12016 KB Output is correct
40 Correct 61 ms 12052 KB Output is correct
41 Correct 41 ms 8948 KB Output is correct
42 Correct 12 ms 4352 KB Output is correct
43 Correct 4 ms 3072 KB Output is correct
44 Correct 4 ms 3072 KB Output is correct
45 Correct 4 ms 3072 KB Output is correct
46 Correct 4 ms 3072 KB Output is correct
47 Correct 5 ms 3072 KB Output is correct
48 Correct 4 ms 3072 KB Output is correct
49 Correct 4 ms 3072 KB Output is correct
50 Correct 4 ms 3072 KB Output is correct
51 Correct 4 ms 3072 KB Output is correct
52 Correct 4 ms 3200 KB Output is correct
53 Correct 4 ms 3072 KB Output is correct
54 Correct 4 ms 3072 KB Output is correct
55 Correct 5 ms 3072 KB Output is correct
56 Correct 4 ms 3072 KB Output is correct
57 Correct 71 ms 9072 KB Output is correct
58 Correct 74 ms 9072 KB Output is correct
59 Correct 82 ms 9072 KB Output is correct
60 Correct 84 ms 9072 KB Output is correct
61 Correct 88 ms 8940 KB Output is correct
62 Correct 68 ms 8944 KB Output is correct
63 Correct 62 ms 8816 KB Output is correct
64 Correct 72 ms 8816 KB Output is correct
65 Correct 73 ms 8944 KB Output is correct
66 Correct 74 ms 8816 KB Output is correct
67 Correct 77 ms 8944 KB Output is correct
68 Correct 89 ms 8944 KB Output is correct
69 Correct 129 ms 9200 KB Output is correct
70 Correct 102 ms 8944 KB Output is correct
71 Correct 5 ms 3072 KB Output is correct
72 Correct 5 ms 3328 KB Output is correct
73 Correct 5 ms 3200 KB Output is correct
74 Correct 5 ms 3200 KB Output is correct
75 Correct 6 ms 3328 KB Output is correct
76 Correct 6 ms 3328 KB Output is correct
77 Correct 6 ms 3328 KB Output is correct
78 Correct 5 ms 3328 KB Output is correct
79 Correct 5 ms 3200 KB Output is correct
80 Correct 97 ms 8980 KB Output is correct
81 Correct 89 ms 8972 KB Output is correct
82 Correct 76 ms 8944 KB Output is correct
83 Correct 80 ms 8944 KB Output is correct
84 Correct 6 ms 3200 KB Output is correct
85 Correct 5 ms 3200 KB Output is correct
86 Correct 5 ms 3200 KB Output is correct
87 Correct 6 ms 3200 KB Output is correct
88 Correct 6 ms 3200 KB Output is correct
89 Correct 22 ms 3200 KB Output is correct
90 Correct 5 ms 3200 KB Output is correct
91 Correct 5 ms 3328 KB Output is correct
92 Correct 5 ms 3200 KB Output is correct
93 Correct 5 ms 3276 KB Output is correct
94 Correct 4 ms 3072 KB Output is correct
95 Correct 4 ms 3072 KB Output is correct
96 Correct 4 ms 3072 KB Output is correct
97 Correct 5 ms 3072 KB Output is correct
98 Correct 4 ms 3072 KB Output is correct
99 Correct 4 ms 3072 KB Output is correct
100 Correct 4 ms 3072 KB Output is correct
101 Correct 4 ms 3072 KB Output is correct
102 Correct 4 ms 3072 KB Output is correct
103 Correct 4 ms 3072 KB Output is correct
104 Correct 9 ms 3840 KB Output is correct
105 Correct 16 ms 5120 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 30 ms 6388 KB Output is correct
108 Correct 37 ms 7540 KB Output is correct
109 Correct 4 ms 3200 KB Output is correct
110 Correct 52 ms 8944 KB Output is correct
111 Correct 60 ms 10480 KB Output is correct
112 Correct 4 ms 3072 KB Output is correct
113 Correct 89 ms 12912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 12016 KB Output is correct
2 Correct 69 ms 12140 KB Output is correct
3 Correct 48 ms 8948 KB Output is correct
4 Correct 11 ms 4480 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 17 ms 5120 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 37 ms 6260 KB Output is correct
9 Correct 41 ms 7540 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 63 ms 8944 KB Output is correct
12 Correct 79 ms 10464 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 11 ms 3200 KB Output is correct
15 Correct 19 ms 3200 KB Output is correct
16 Correct 31 ms 3328 KB Output is correct
17 Correct 11 ms 3200 KB Output is correct
18 Correct 20 ms 3200 KB Output is correct
19 Correct 27 ms 3264 KB Output is correct
20 Correct 11 ms 3200 KB Output is correct
21 Correct 16 ms 3200 KB Output is correct
22 Correct 27 ms 3356 KB Output is correct
23 Correct 4 ms 3072 KB Output is correct
24 Correct 4 ms 3072 KB Output is correct
25 Correct 4 ms 3200 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 4 ms 3072 KB Output is correct
28 Correct 8 ms 3072 KB Output is correct
29 Correct 6 ms 3072 KB Output is correct
30 Correct 4 ms 3072 KB Output is correct
31 Correct 4 ms 3072 KB Output is correct
32 Correct 4 ms 3072 KB Output is correct
33 Correct 4 ms 3072 KB Output is correct
34 Correct 4 ms 3072 KB Output is correct
35 Correct 4 ms 3068 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 3072 KB Output is correct
39 Correct 4 ms 3072 KB Output is correct
40 Incorrect 4 ms 3072 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 12016 KB Output is correct
2 Correct 69 ms 12140 KB Output is correct
3 Correct 48 ms 8948 KB Output is correct
4 Correct 11 ms 4480 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 17 ms 5120 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 37 ms 6260 KB Output is correct
9 Correct 41 ms 7540 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 63 ms 8944 KB Output is correct
12 Correct 79 ms 10464 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 5 ms 3072 KB Output is correct
16 Correct 4 ms 3072 KB Output is correct
17 Correct 4 ms 3072 KB Output is correct
18 Correct 4 ms 3072 KB Output is correct
19 Correct 4 ms 3072 KB Output is correct
20 Correct 4 ms 3072 KB Output is correct
21 Correct 4 ms 3072 KB Output is correct
22 Correct 4 ms 3072 KB Output is correct
23 Correct 4 ms 3072 KB Output is correct
24 Correct 4 ms 3072 KB Output is correct
25 Correct 4 ms 3072 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 4 ms 3072 KB Output is correct
28 Correct 4 ms 3072 KB Output is correct
29 Correct 4 ms 3072 KB Output is correct
30 Correct 4 ms 3072 KB Output is correct
31 Correct 5 ms 3072 KB Output is correct
32 Correct 4 ms 3072 KB Output is correct
33 Correct 4 ms 3072 KB Output is correct
34 Correct 4 ms 3072 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 3072 KB Output is correct
39 Correct 63 ms 12016 KB Output is correct
40 Correct 61 ms 12052 KB Output is correct
41 Correct 41 ms 8948 KB Output is correct
42 Correct 12 ms 4352 KB Output is correct
43 Correct 4 ms 3072 KB Output is correct
44 Correct 4 ms 3072 KB Output is correct
45 Correct 4 ms 3072 KB Output is correct
46 Correct 4 ms 3072 KB Output is correct
47 Correct 5 ms 3072 KB Output is correct
48 Correct 4 ms 3072 KB Output is correct
49 Correct 4 ms 3072 KB Output is correct
50 Correct 4 ms 3072 KB Output is correct
51 Correct 4 ms 3072 KB Output is correct
52 Correct 4 ms 3200 KB Output is correct
53 Correct 4 ms 3072 KB Output is correct
54 Correct 4 ms 3072 KB Output is correct
55 Correct 5 ms 3072 KB Output is correct
56 Correct 4 ms 3072 KB Output is correct
57 Correct 71 ms 9072 KB Output is correct
58 Correct 74 ms 9072 KB Output is correct
59 Correct 82 ms 9072 KB Output is correct
60 Correct 84 ms 9072 KB Output is correct
61 Correct 88 ms 8940 KB Output is correct
62 Correct 68 ms 8944 KB Output is correct
63 Correct 62 ms 8816 KB Output is correct
64 Correct 72 ms 8816 KB Output is correct
65 Correct 73 ms 8944 KB Output is correct
66 Correct 74 ms 8816 KB Output is correct
67 Correct 77 ms 8944 KB Output is correct
68 Correct 89 ms 8944 KB Output is correct
69 Correct 129 ms 9200 KB Output is correct
70 Correct 102 ms 8944 KB Output is correct
71 Correct 5 ms 3072 KB Output is correct
72 Correct 5 ms 3328 KB Output is correct
73 Correct 5 ms 3200 KB Output is correct
74 Correct 5 ms 3200 KB Output is correct
75 Correct 6 ms 3328 KB Output is correct
76 Correct 6 ms 3328 KB Output is correct
77 Correct 6 ms 3328 KB Output is correct
78 Correct 5 ms 3328 KB Output is correct
79 Correct 5 ms 3200 KB Output is correct
80 Correct 97 ms 8980 KB Output is correct
81 Correct 89 ms 8972 KB Output is correct
82 Correct 76 ms 8944 KB Output is correct
83 Correct 80 ms 8944 KB Output is correct
84 Correct 6 ms 3200 KB Output is correct
85 Correct 5 ms 3200 KB Output is correct
86 Correct 5 ms 3200 KB Output is correct
87 Correct 6 ms 3200 KB Output is correct
88 Correct 6 ms 3200 KB Output is correct
89 Correct 22 ms 3200 KB Output is correct
90 Correct 5 ms 3200 KB Output is correct
91 Correct 5 ms 3328 KB Output is correct
92 Correct 5 ms 3200 KB Output is correct
93 Correct 5 ms 3276 KB Output is correct
94 Correct 4 ms 3072 KB Output is correct
95 Correct 4 ms 3072 KB Output is correct
96 Correct 4 ms 3072 KB Output is correct
97 Correct 5 ms 3072 KB Output is correct
98 Correct 4 ms 3072 KB Output is correct
99 Correct 4 ms 3072 KB Output is correct
100 Correct 4 ms 3072 KB Output is correct
101 Correct 4 ms 3072 KB Output is correct
102 Correct 4 ms 3072 KB Output is correct
103 Correct 4 ms 3072 KB Output is correct
104 Correct 9 ms 3840 KB Output is correct
105 Correct 16 ms 5120 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 30 ms 6388 KB Output is correct
108 Correct 37 ms 7540 KB Output is correct
109 Correct 4 ms 3200 KB Output is correct
110 Correct 52 ms 8944 KB Output is correct
111 Correct 60 ms 10480 KB Output is correct
112 Correct 4 ms 3072 KB Output is correct
113 Correct 89 ms 12912 KB Output is correct
114 Execution timed out 1072 ms 6148 KB Time limit exceeded
115 Halted 0 ms 0 KB -