Submission #104434

# Submission time Handle Problem Language Result Execution time Memory
104434 2019-04-06T20:18:46 Z CaroLinda Dreaming (IOI13_dreaming) C++14
47 / 100
176 ms 11996 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] ;
int dd[4][MAXN] ;

vector<pii> adj[MAXN] ;

//utilities
void atribution(int x)
{lp(i,0,N) dd[x][i] = d[i] ;}

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

void dfs(int x)
{
    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 diam)
{
    lp(i,0,N)
    {
        if(dd[x][i] == -1) continue ;
        int a = dd[x][i] , b = dd[y][i] ;
        a = max(a,b) ;
        diam = min(diam, a) ;
    }
    return diam ;
}

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

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

    ini(0) ; dfs(0) ;
    int A1 = findMax() ;
    ini(A1) , dfs(A1) ;
    atribution(0) ;
    int B1 = findMax() ;
    ini(B1) , dfs(B1) ;
    atribution(1) ;

    int X ;
    lp(i,0,N)
        if(d[i] == -1) { X = i ; break ; }

    ini(X) , dfs(X) ;
    int A2 = findMax() ;
    ini(A2) , dfs(A2) ;
    atribution(2) ;
    int B2 = findMax() ;
    ini(B2) , dfs(B2) ;
    atribution(3) ;

    int d1 = dd[0][B1] ;
    int d2 = dd[2][B2] ;

    radio1 = findRadio(0,1 , d1) ;
    radio2 = findRadio(2,3 , d2) ;

    return max3(radio1 + radio2 + L , d1 , d2) ;

}

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:33:8:
     lp(i , 0 , adj[x].size() )
        ~~~~~~~~~~~~~~~~~~~~~         
dreaming.cpp:33:5: note: in expansion of macro 'lp'
     lp(i , 0 , adj[x].size() )
     ^~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:80:17: warning: 'X' may be used uninitialized in this function [-Wmaybe-uninitialized]
     ini(X) , dfs(X) ;
              ~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 60 ms 11256 KB Output is correct
2 Correct 67 ms 11308 KB Output is correct
3 Correct 41 ms 8440 KB Output is correct
4 Correct 12 ms 4352 KB Output is correct
5 Correct 11 ms 3868 KB Output is correct
6 Correct 19 ms 4864 KB Output is correct
7 Correct 5 ms 3200 KB Output is correct
8 Correct 35 ms 6136 KB Output is correct
9 Correct 40 ms 7288 KB Output is correct
10 Correct 5 ms 3072 KB Output is correct
11 Correct 61 ms 8696 KB Output is correct
12 Correct 81 ms 9976 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 11256 KB Output is correct
2 Correct 67 ms 11308 KB Output is correct
3 Correct 41 ms 8440 KB Output is correct
4 Correct 12 ms 4352 KB Output is correct
5 Correct 11 ms 3868 KB Output is correct
6 Correct 19 ms 4864 KB Output is correct
7 Correct 5 ms 3200 KB Output is correct
8 Correct 35 ms 6136 KB Output is correct
9 Correct 40 ms 7288 KB Output is correct
10 Correct 5 ms 3072 KB Output is correct
11 Correct 61 ms 8696 KB Output is correct
12 Correct 81 ms 9976 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 4 ms 3104 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 4 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 5 ms 3072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 11256 KB Output is correct
2 Correct 67 ms 11308 KB Output is correct
3 Correct 41 ms 8440 KB Output is correct
4 Correct 12 ms 4352 KB Output is correct
5 Correct 11 ms 3868 KB Output is correct
6 Correct 19 ms 4864 KB Output is correct
7 Correct 5 ms 3200 KB Output is correct
8 Correct 35 ms 6136 KB Output is correct
9 Correct 40 ms 7288 KB Output is correct
10 Correct 5 ms 3072 KB Output is correct
11 Correct 61 ms 8696 KB Output is correct
12 Correct 81 ms 9976 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 4 ms 3104 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 4 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 5 ms 3072 KB Output is correct
39 Correct 65 ms 11420 KB Output is correct
40 Correct 84 ms 11224 KB Output is correct
41 Correct 45 ms 8476 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 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 3072 KB Output is correct
52 Correct 4 ms 3072 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 83 ms 9848 KB Output is correct
58 Correct 91 ms 9820 KB Output is correct
59 Correct 79 ms 9724 KB Output is correct
60 Correct 75 ms 9720 KB Output is correct
61 Correct 86 ms 9784 KB Output is correct
62 Correct 82 ms 9592 KB Output is correct
63 Correct 72 ms 9592 KB Output is correct
64 Correct 176 ms 9464 KB Output is correct
65 Correct 86 ms 9468 KB Output is correct
66 Correct 76 ms 9464 KB Output is correct
67 Correct 106 ms 9720 KB Output is correct
68 Correct 96 ms 9704 KB Output is correct
69 Correct 79 ms 9724 KB Output is correct
70 Correct 81 ms 9720 KB Output is correct
71 Correct 4 ms 3072 KB Output is correct
72 Correct 6 ms 3328 KB Output is correct
73 Correct 6 ms 3300 KB Output is correct
74 Correct 5 ms 3328 KB Output is correct
75 Correct 6 ms 3328 KB Output is correct
76 Correct 6 ms 3328 KB Output is correct
77 Correct 5 ms 3328 KB Output is correct
78 Correct 6 ms 3328 KB Output is correct
79 Correct 6 ms 3328 KB Output is correct
80 Correct 97 ms 9720 KB Output is correct
81 Correct 78 ms 9720 KB Output is correct
82 Correct 75 ms 9592 KB Output is correct
83 Correct 90 ms 9720 KB Output is correct
84 Correct 5 ms 3200 KB Output is correct
85 Correct 5 ms 3200 KB Output is correct
86 Correct 6 ms 3200 KB Output is correct
87 Correct 5 ms 3200 KB Output is correct
88 Correct 5 ms 3328 KB Output is correct
89 Correct 6 ms 3200 KB Output is correct
90 Correct 6 ms 3328 KB Output is correct
91 Correct 5 ms 3328 KB Output is correct
92 Correct 6 ms 3328 KB Output is correct
93 Correct 5 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 4 ms 3072 KB Output is correct
99 Correct 4 ms 3072 KB Output is correct
100 Correct 5 ms 3200 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 10 ms 3840 KB Output is correct
105 Correct 18 ms 4864 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 33 ms 6136 KB Output is correct
108 Correct 45 ms 7288 KB Output is correct
109 Correct 5 ms 3108 KB Output is correct
110 Correct 59 ms 8824 KB Output is correct
111 Correct 62 ms 9976 KB Output is correct
112 Correct 4 ms 3200 KB Output is correct
113 Correct 94 ms 11996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 6904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 11256 KB Output is correct
2 Correct 67 ms 11308 KB Output is correct
3 Correct 41 ms 8440 KB Output is correct
4 Correct 12 ms 4352 KB Output is correct
5 Correct 11 ms 3868 KB Output is correct
6 Correct 19 ms 4864 KB Output is correct
7 Correct 5 ms 3200 KB Output is correct
8 Correct 35 ms 6136 KB Output is correct
9 Correct 40 ms 7288 KB Output is correct
10 Correct 5 ms 3072 KB Output is correct
11 Correct 61 ms 8696 KB Output is correct
12 Correct 81 ms 9976 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Incorrect 4 ms 3200 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 11256 KB Output is correct
2 Correct 67 ms 11308 KB Output is correct
3 Correct 41 ms 8440 KB Output is correct
4 Correct 12 ms 4352 KB Output is correct
5 Correct 11 ms 3868 KB Output is correct
6 Correct 19 ms 4864 KB Output is correct
7 Correct 5 ms 3200 KB Output is correct
8 Correct 35 ms 6136 KB Output is correct
9 Correct 40 ms 7288 KB Output is correct
10 Correct 5 ms 3072 KB Output is correct
11 Correct 61 ms 8696 KB Output is correct
12 Correct 81 ms 9976 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 4 ms 3072 KB Output is correct
15 Correct 4 ms 3104 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 4 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 5 ms 3072 KB Output is correct
39 Correct 65 ms 11420 KB Output is correct
40 Correct 84 ms 11224 KB Output is correct
41 Correct 45 ms 8476 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 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 3072 KB Output is correct
52 Correct 4 ms 3072 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 83 ms 9848 KB Output is correct
58 Correct 91 ms 9820 KB Output is correct
59 Correct 79 ms 9724 KB Output is correct
60 Correct 75 ms 9720 KB Output is correct
61 Correct 86 ms 9784 KB Output is correct
62 Correct 82 ms 9592 KB Output is correct
63 Correct 72 ms 9592 KB Output is correct
64 Correct 176 ms 9464 KB Output is correct
65 Correct 86 ms 9468 KB Output is correct
66 Correct 76 ms 9464 KB Output is correct
67 Correct 106 ms 9720 KB Output is correct
68 Correct 96 ms 9704 KB Output is correct
69 Correct 79 ms 9724 KB Output is correct
70 Correct 81 ms 9720 KB Output is correct
71 Correct 4 ms 3072 KB Output is correct
72 Correct 6 ms 3328 KB Output is correct
73 Correct 6 ms 3300 KB Output is correct
74 Correct 5 ms 3328 KB Output is correct
75 Correct 6 ms 3328 KB Output is correct
76 Correct 6 ms 3328 KB Output is correct
77 Correct 5 ms 3328 KB Output is correct
78 Correct 6 ms 3328 KB Output is correct
79 Correct 6 ms 3328 KB Output is correct
80 Correct 97 ms 9720 KB Output is correct
81 Correct 78 ms 9720 KB Output is correct
82 Correct 75 ms 9592 KB Output is correct
83 Correct 90 ms 9720 KB Output is correct
84 Correct 5 ms 3200 KB Output is correct
85 Correct 5 ms 3200 KB Output is correct
86 Correct 6 ms 3200 KB Output is correct
87 Correct 5 ms 3200 KB Output is correct
88 Correct 5 ms 3328 KB Output is correct
89 Correct 6 ms 3200 KB Output is correct
90 Correct 6 ms 3328 KB Output is correct
91 Correct 5 ms 3328 KB Output is correct
92 Correct 6 ms 3328 KB Output is correct
93 Correct 5 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 4 ms 3072 KB Output is correct
99 Correct 4 ms 3072 KB Output is correct
100 Correct 5 ms 3200 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 10 ms 3840 KB Output is correct
105 Correct 18 ms 4864 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 33 ms 6136 KB Output is correct
108 Correct 45 ms 7288 KB Output is correct
109 Correct 5 ms 3108 KB Output is correct
110 Correct 59 ms 8824 KB Output is correct
111 Correct 62 ms 9976 KB Output is correct
112 Correct 4 ms 3200 KB Output is correct
113 Correct 94 ms 11996 KB Output is correct
114 Incorrect 27 ms 6904 KB Output isn't correct
115 Halted 0 ms 0 KB -