Submission #104476

# Submission time Handle Problem Language Result Execution time Memory
104476 2019-04-07T00:47:10 Z CaroLinda Dreaming (IOI13_dreaming) C++14
47 / 100
113 ms 11508 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 ;

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

    if(M < N-2)
    {
        sort(edge.begin() , edge.end()) ;
        reverse(edge.begin() , edge.end()) ;
        lp(i,0,M) ans = max(ans , edge[i]) ;
        if(M <= 3)
            lp(i,0,3) edge.pb(0) ;
        ans = max( ans , edge[0] + edge[1] + L ) ;
        ans = max( ans , edge[1] + edge[2] + 2*L ) ;
        return ans ;
    }

    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() )
     ^~
# Verdict Execution time Memory Grader output
1 Correct 67 ms 10608 KB Output is correct
2 Correct 73 ms 10608 KB Output is correct
3 Correct 42 ms 8052 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 18 ms 4864 KB Output is correct
7 Correct 5 ms 3072 KB Output is correct
8 Correct 33 ms 5876 KB Output is correct
9 Correct 43 ms 6900 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 58 ms 8180 KB Output is correct
12 Correct 88 ms 9560 KB Output is correct
13 Correct 4 ms 3200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 10608 KB Output is correct
2 Correct 73 ms 10608 KB Output is correct
3 Correct 42 ms 8052 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 18 ms 4864 KB Output is correct
7 Correct 5 ms 3072 KB Output is correct
8 Correct 33 ms 5876 KB Output is correct
9 Correct 43 ms 6900 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 58 ms 8180 KB Output is correct
12 Correct 88 ms 9560 KB Output is correct
13 Correct 4 ms 3200 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 5 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 5 ms 3072 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 5 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 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
# Verdict Execution time Memory Grader output
1 Correct 67 ms 10608 KB Output is correct
2 Correct 73 ms 10608 KB Output is correct
3 Correct 42 ms 8052 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 18 ms 4864 KB Output is correct
7 Correct 5 ms 3072 KB Output is correct
8 Correct 33 ms 5876 KB Output is correct
9 Correct 43 ms 6900 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 58 ms 8180 KB Output is correct
12 Correct 88 ms 9560 KB Output is correct
13 Correct 4 ms 3200 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 5 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 5 ms 3072 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 5 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 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 83 ms 10736 KB Output is correct
40 Correct 97 ms 10656 KB Output is correct
41 Correct 43 ms 8052 KB Output is correct
42 Correct 12 ms 4224 KB Output is correct
43 Correct 4 ms 3072 KB Output is correct
44 Correct 5 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 3044 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 5 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 86 ms 9072 KB Output is correct
58 Correct 87 ms 9072 KB Output is correct
59 Correct 92 ms 9072 KB Output is correct
60 Correct 81 ms 9012 KB Output is correct
61 Correct 84 ms 8928 KB Output is correct
62 Correct 78 ms 8944 KB Output is correct
63 Correct 73 ms 8816 KB Output is correct
64 Correct 78 ms 8812 KB Output is correct
65 Correct 77 ms 8816 KB Output is correct
66 Correct 74 ms 8816 KB Output is correct
67 Correct 84 ms 8944 KB Output is correct
68 Correct 81 ms 8944 KB Output is correct
69 Correct 98 ms 9072 KB Output is correct
70 Correct 90 ms 8944 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 3328 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 6 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 113 ms 9084 KB Output is correct
81 Correct 81 ms 8944 KB Output is correct
82 Correct 83 ms 8964 KB Output is correct
83 Correct 74 ms 8948 KB Output is correct
84 Correct 5 ms 3200 KB Output is correct
85 Correct 6 ms 3200 KB Output is correct
86 Correct 5 ms 3200 KB Output is correct
87 Correct 5 ms 3200 KB Output is correct
88 Correct 6 ms 3200 KB Output is correct
89 Correct 6 ms 3200 KB Output is correct
90 Correct 5 ms 3200 KB Output is correct
91 Correct 6 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 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 5 ms 3072 KB Output is correct
103 Correct 4 ms 3072 KB Output is correct
104 Correct 10 ms 3812 KB Output is correct
105 Correct 28 ms 4864 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 31 ms 5884 KB Output is correct
108 Correct 40 ms 7036 KB Output is correct
109 Correct 5 ms 3200 KB Output is correct
110 Correct 72 ms 8176 KB Output is correct
111 Correct 63 ms 9328 KB Output is correct
112 Correct 4 ms 3072 KB Output is correct
113 Correct 93 ms 11508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 5120 KB Output is correct
2 Correct 24 ms 5120 KB Output is correct
3 Correct 23 ms 5120 KB Output is correct
4 Correct 27 ms 5120 KB Output is correct
5 Correct 22 ms 5120 KB Output is correct
6 Correct 22 ms 5368 KB Output is correct
7 Correct 27 ms 5240 KB Output is correct
8 Correct 23 ms 5120 KB Output is correct
9 Correct 22 ms 5120 KB Output is correct
10 Correct 25 ms 5248 KB Output is correct
11 Correct 3 ms 2688 KB Output is correct
12 Correct 3 ms 2688 KB Output is correct
13 Correct 4 ms 2688 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 3 ms 2688 KB Output is correct
20 Incorrect 4 ms 3072 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 67 ms 10608 KB Output is correct
2 Correct 73 ms 10608 KB Output is correct
3 Correct 42 ms 8052 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 18 ms 4864 KB Output is correct
7 Correct 5 ms 3072 KB Output is correct
8 Correct 33 ms 5876 KB Output is correct
9 Correct 43 ms 6900 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 58 ms 8180 KB Output is correct
12 Correct 88 ms 9560 KB Output is correct
13 Correct 4 ms 3200 KB Output is correct
14 Incorrect 4 ms 2688 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 67 ms 10608 KB Output is correct
2 Correct 73 ms 10608 KB Output is correct
3 Correct 42 ms 8052 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 11 ms 3840 KB Output is correct
6 Correct 18 ms 4864 KB Output is correct
7 Correct 5 ms 3072 KB Output is correct
8 Correct 33 ms 5876 KB Output is correct
9 Correct 43 ms 6900 KB Output is correct
10 Correct 4 ms 3200 KB Output is correct
11 Correct 58 ms 8180 KB Output is correct
12 Correct 88 ms 9560 KB Output is correct
13 Correct 4 ms 3200 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 5 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 5 ms 3072 KB Output is correct
26 Correct 4 ms 3072 KB Output is correct
27 Correct 5 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 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 83 ms 10736 KB Output is correct
40 Correct 97 ms 10656 KB Output is correct
41 Correct 43 ms 8052 KB Output is correct
42 Correct 12 ms 4224 KB Output is correct
43 Correct 4 ms 3072 KB Output is correct
44 Correct 5 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 3044 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 5 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 86 ms 9072 KB Output is correct
58 Correct 87 ms 9072 KB Output is correct
59 Correct 92 ms 9072 KB Output is correct
60 Correct 81 ms 9012 KB Output is correct
61 Correct 84 ms 8928 KB Output is correct
62 Correct 78 ms 8944 KB Output is correct
63 Correct 73 ms 8816 KB Output is correct
64 Correct 78 ms 8812 KB Output is correct
65 Correct 77 ms 8816 KB Output is correct
66 Correct 74 ms 8816 KB Output is correct
67 Correct 84 ms 8944 KB Output is correct
68 Correct 81 ms 8944 KB Output is correct
69 Correct 98 ms 9072 KB Output is correct
70 Correct 90 ms 8944 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 3328 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 6 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 113 ms 9084 KB Output is correct
81 Correct 81 ms 8944 KB Output is correct
82 Correct 83 ms 8964 KB Output is correct
83 Correct 74 ms 8948 KB Output is correct
84 Correct 5 ms 3200 KB Output is correct
85 Correct 6 ms 3200 KB Output is correct
86 Correct 5 ms 3200 KB Output is correct
87 Correct 5 ms 3200 KB Output is correct
88 Correct 6 ms 3200 KB Output is correct
89 Correct 6 ms 3200 KB Output is correct
90 Correct 5 ms 3200 KB Output is correct
91 Correct 6 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 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 5 ms 3072 KB Output is correct
103 Correct 4 ms 3072 KB Output is correct
104 Correct 10 ms 3812 KB Output is correct
105 Correct 28 ms 4864 KB Output is correct
106 Correct 4 ms 3072 KB Output is correct
107 Correct 31 ms 5884 KB Output is correct
108 Correct 40 ms 7036 KB Output is correct
109 Correct 5 ms 3200 KB Output is correct
110 Correct 72 ms 8176 KB Output is correct
111 Correct 63 ms 9328 KB Output is correct
112 Correct 4 ms 3072 KB Output is correct
113 Correct 93 ms 11508 KB Output is correct
114 Correct 25 ms 5120 KB Output is correct
115 Correct 24 ms 5120 KB Output is correct
116 Correct 23 ms 5120 KB Output is correct
117 Correct 27 ms 5120 KB Output is correct
118 Correct 22 ms 5120 KB Output is correct
119 Correct 22 ms 5368 KB Output is correct
120 Correct 27 ms 5240 KB Output is correct
121 Correct 23 ms 5120 KB Output is correct
122 Correct 22 ms 5120 KB Output is correct
123 Correct 25 ms 5248 KB Output is correct
124 Correct 3 ms 2688 KB Output is correct
125 Correct 3 ms 2688 KB Output is correct
126 Correct 4 ms 2688 KB Output is correct
127 Correct 4 ms 2688 KB Output is correct
128 Correct 4 ms 2688 KB Output is correct
129 Correct 4 ms 2688 KB Output is correct
130 Correct 4 ms 2688 KB Output is correct
131 Correct 4 ms 2688 KB Output is correct
132 Correct 3 ms 2688 KB Output is correct
133 Incorrect 4 ms 3072 KB Output isn't correct
134 Halted 0 ms 0 KB -