답안 #104473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104473 2019-04-07T00:23:58 Z CaroLinda 꿈 (IOI13_dreaming) C++14
47 / 100
1000 ms 11000 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];

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 ;
        dfs(v) ;
    }
}

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

int findRadio(int X , int Y)
{
    int ans = d[X] ;
    lp(i,0,N)
    {
        if(d[i] == -1) continue ;
        int a = d[i] , b = dX[i] ;
        a = max(a,b) ;
        ans = min(ans , a) ;
    }
    return ans ;
}


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

    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]) ) ;
    }

    lp(i,0,N)
        if(!marc[i])
        {
            ini(i) ; dfs(i) ;
            int X = findMax() ;
            ini(X) ; dfs(X) ;
            atribution() ;
            int Y = findMax() ;
            ini(Y) ; dfs(Y) ;
            int k = findRadio(X,Y) ;
            radios.pb(k) ;
            ans = max(ans, d[X]) ;
            //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 72 ms 10232 KB Output is correct
2 Correct 82 ms 10232 KB Output is correct
3 Correct 46 ms 7800 KB Output is correct
4 Correct 11 ms 4096 KB Output is correct
5 Correct 10 ms 3712 KB Output is correct
6 Correct 18 ms 4860 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 41 ms 6776 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 58 ms 7928 KB Output is correct
12 Correct 73 ms 9080 KB Output is correct
13 Correct 5 ms 3172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 10232 KB Output is correct
2 Correct 82 ms 10232 KB Output is correct
3 Correct 46 ms 7800 KB Output is correct
4 Correct 11 ms 4096 KB Output is correct
5 Correct 10 ms 3712 KB Output is correct
6 Correct 18 ms 4860 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 41 ms 6776 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 58 ms 7928 KB Output is correct
12 Correct 73 ms 9080 KB Output is correct
13 Correct 5 ms 3172 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 4 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 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 5 ms 3072 KB Output is correct
35 Correct 5 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 72 ms 10232 KB Output is correct
2 Correct 82 ms 10232 KB Output is correct
3 Correct 46 ms 7800 KB Output is correct
4 Correct 11 ms 4096 KB Output is correct
5 Correct 10 ms 3712 KB Output is correct
6 Correct 18 ms 4860 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 41 ms 6776 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 58 ms 7928 KB Output is correct
12 Correct 73 ms 9080 KB Output is correct
13 Correct 5 ms 3172 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 4 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 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 5 ms 3072 KB Output is correct
35 Correct 5 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 78 ms 10232 KB Output is correct
40 Correct 77 ms 10232 KB Output is correct
41 Correct 39 ms 7800 KB Output is correct
42 Correct 12 ms 4224 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 4 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 3200 KB Output is correct
52 Correct 4 ms 3044 KB Output is correct
53 Correct 4 ms 3072 KB Output is correct
54 Correct 4 ms 3072 KB Output is correct
55 Correct 4 ms 3072 KB Output is correct
56 Correct 4 ms 3072 KB Output is correct
57 Correct 75 ms 8624 KB Output is correct
58 Correct 78 ms 8696 KB Output is correct
59 Correct 73 ms 8572 KB Output is correct
60 Correct 83 ms 8568 KB Output is correct
61 Correct 77 ms 8696 KB Output is correct
62 Correct 74 ms 8568 KB Output is correct
63 Correct 74 ms 8440 KB Output is correct
64 Correct 71 ms 8440 KB Output is correct
65 Correct 71 ms 8472 KB Output is correct
66 Correct 85 ms 8440 KB Output is correct
67 Correct 87 ms 8568 KB Output is correct
68 Correct 79 ms 8696 KB Output is correct
69 Correct 84 ms 8568 KB Output is correct
70 Correct 88 ms 8568 KB Output is correct
71 Correct 4 ms 3072 KB Output is correct
72 Correct 6 ms 3328 KB Output is correct
73 Correct 5 ms 3328 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 6 ms 3328 KB Output is correct
79 Correct 5 ms 3200 KB Output is correct
80 Correct 93 ms 8568 KB Output is correct
81 Correct 89 ms 8568 KB Output is correct
82 Correct 75 ms 8568 KB Output is correct
83 Correct 73 ms 8568 KB Output is correct
84 Correct 5 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 5 ms 3200 KB Output is correct
89 Correct 5 ms 3200 KB Output is correct
90 Correct 6 ms 3200 KB Output is correct
91 Correct 8 ms 3328 KB Output is correct
92 Correct 6 ms 3200 KB Output is correct
93 Correct 6 ms 3200 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 4 ms 3072 KB Output is correct
98 Correct 5 ms 3072 KB Output is correct
99 Correct 4 ms 3072 KB Output is correct
100 Correct 5 ms 3072 KB Output is correct
101 Correct 5 ms 3072 KB Output is correct
102 Correct 4 ms 3100 KB Output is correct
103 Correct 4 ms 3100 KB Output is correct
104 Correct 11 ms 3712 KB Output is correct
105 Correct 18 ms 4608 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 33 ms 5756 KB Output is correct
108 Correct 41 ms 6776 KB Output is correct
109 Correct 4 ms 3072 KB Output is correct
110 Correct 61 ms 7928 KB Output is correct
111 Correct 73 ms 9232 KB Output is correct
112 Correct 5 ms 3200 KB Output is correct
113 Correct 128 ms 11000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 6008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 10232 KB Output is correct
2 Correct 82 ms 10232 KB Output is correct
3 Correct 46 ms 7800 KB Output is correct
4 Correct 11 ms 4096 KB Output is correct
5 Correct 10 ms 3712 KB Output is correct
6 Correct 18 ms 4860 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 41 ms 6776 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 58 ms 7928 KB Output is correct
12 Correct 73 ms 9080 KB Output is correct
13 Correct 5 ms 3172 KB Output is correct
14 Correct 14 ms 3072 KB Output is correct
15 Correct 28 ms 3200 KB Output is correct
16 Correct 43 ms 3200 KB Output is correct
17 Correct 15 ms 3200 KB Output is correct
18 Correct 24 ms 3200 KB Output is correct
19 Correct 37 ms 3320 KB Output is correct
20 Correct 12 ms 3200 KB Output is correct
21 Correct 23 ms 3200 KB Output is correct
22 Correct 33 ms 3328 KB Output is correct
23 Correct 4 ms 3200 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 10 ms 3072 KB Output is correct
29 Correct 8 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 3200 KB Output is correct
33 Correct 5 ms 3072 KB Output is correct
34 Correct 6 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 5 ms 3072 KB Output is correct
38 Correct 10 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 72 ms 10232 KB Output is correct
2 Correct 82 ms 10232 KB Output is correct
3 Correct 46 ms 7800 KB Output is correct
4 Correct 11 ms 4096 KB Output is correct
5 Correct 10 ms 3712 KB Output is correct
6 Correct 18 ms 4860 KB Output is correct
7 Correct 4 ms 3072 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 41 ms 6776 KB Output is correct
10 Correct 4 ms 3072 KB Output is correct
11 Correct 58 ms 7928 KB Output is correct
12 Correct 73 ms 9080 KB Output is correct
13 Correct 5 ms 3172 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 4 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 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 5 ms 3072 KB Output is correct
35 Correct 5 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 78 ms 10232 KB Output is correct
40 Correct 77 ms 10232 KB Output is correct
41 Correct 39 ms 7800 KB Output is correct
42 Correct 12 ms 4224 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 4 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 3200 KB Output is correct
52 Correct 4 ms 3044 KB Output is correct
53 Correct 4 ms 3072 KB Output is correct
54 Correct 4 ms 3072 KB Output is correct
55 Correct 4 ms 3072 KB Output is correct
56 Correct 4 ms 3072 KB Output is correct
57 Correct 75 ms 8624 KB Output is correct
58 Correct 78 ms 8696 KB Output is correct
59 Correct 73 ms 8572 KB Output is correct
60 Correct 83 ms 8568 KB Output is correct
61 Correct 77 ms 8696 KB Output is correct
62 Correct 74 ms 8568 KB Output is correct
63 Correct 74 ms 8440 KB Output is correct
64 Correct 71 ms 8440 KB Output is correct
65 Correct 71 ms 8472 KB Output is correct
66 Correct 85 ms 8440 KB Output is correct
67 Correct 87 ms 8568 KB Output is correct
68 Correct 79 ms 8696 KB Output is correct
69 Correct 84 ms 8568 KB Output is correct
70 Correct 88 ms 8568 KB Output is correct
71 Correct 4 ms 3072 KB Output is correct
72 Correct 6 ms 3328 KB Output is correct
73 Correct 5 ms 3328 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 6 ms 3328 KB Output is correct
79 Correct 5 ms 3200 KB Output is correct
80 Correct 93 ms 8568 KB Output is correct
81 Correct 89 ms 8568 KB Output is correct
82 Correct 75 ms 8568 KB Output is correct
83 Correct 73 ms 8568 KB Output is correct
84 Correct 5 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 5 ms 3200 KB Output is correct
89 Correct 5 ms 3200 KB Output is correct
90 Correct 6 ms 3200 KB Output is correct
91 Correct 8 ms 3328 KB Output is correct
92 Correct 6 ms 3200 KB Output is correct
93 Correct 6 ms 3200 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 4 ms 3072 KB Output is correct
98 Correct 5 ms 3072 KB Output is correct
99 Correct 4 ms 3072 KB Output is correct
100 Correct 5 ms 3072 KB Output is correct
101 Correct 5 ms 3072 KB Output is correct
102 Correct 4 ms 3100 KB Output is correct
103 Correct 4 ms 3100 KB Output is correct
104 Correct 11 ms 3712 KB Output is correct
105 Correct 18 ms 4608 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 33 ms 5756 KB Output is correct
108 Correct 41 ms 6776 KB Output is correct
109 Correct 4 ms 3072 KB Output is correct
110 Correct 61 ms 7928 KB Output is correct
111 Correct 73 ms 9232 KB Output is correct
112 Correct 5 ms 3200 KB Output is correct
113 Correct 128 ms 11000 KB Output is correct
114 Execution timed out 1082 ms 6008 KB Time limit exceeded
115 Halted 0 ms 0 KB -