Submission #37941

# Submission time Handle Problem Language Result Execution time Memory
37941 2017-12-29T11:58:27 Z 14kg Dreaming (IOI13_dreaming) C++11
14 / 100
56 ms 10232 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[2]?MAX[3]+MAX[2]+L:0,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);
                                           ~~~~~~~~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 53 ms 10232 KB Output is correct
2 Correct 54 ms 10020 KB Output is correct
3 Correct 45 ms 8824 KB Output is correct
4 Correct 11 ms 3712 KB Output is correct
5 Correct 9 ms 3328 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 29 ms 5880 KB Output is correct
9 Correct 36 ms 7680 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 56 ms 8184 KB Output is correct
12 Correct 56 ms 9208 KB Output is correct
13 Correct 4 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 10232 KB Output is correct
2 Correct 54 ms 10020 KB Output is correct
3 Correct 45 ms 8824 KB Output is correct
4 Correct 11 ms 3712 KB Output is correct
5 Correct 9 ms 3328 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 29 ms 5880 KB Output is correct
9 Correct 36 ms 7680 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 56 ms 8184 KB Output is correct
12 Correct 56 ms 9208 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 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 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 2816 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Incorrect 3 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 10232 KB Output is correct
2 Correct 54 ms 10020 KB Output is correct
3 Correct 45 ms 8824 KB Output is correct
4 Correct 11 ms 3712 KB Output is correct
5 Correct 9 ms 3328 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 29 ms 5880 KB Output is correct
9 Correct 36 ms 7680 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 56 ms 8184 KB Output is correct
12 Correct 56 ms 9208 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 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 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 2816 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Incorrect 3 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 5248 KB Output is correct
2 Correct 26 ms 5160 KB Output is correct
3 Correct 24 ms 5248 KB Output is correct
4 Correct 23 ms 5120 KB Output is correct
5 Correct 23 ms 5248 KB Output is correct
6 Correct 24 ms 5376 KB Output is correct
7 Correct 25 ms 5368 KB Output is correct
8 Correct 27 ms 5120 KB Output is correct
9 Correct 27 ms 5120 KB Output is correct
10 Correct 26 ms 5248 KB Output is correct
11 Correct 4 ms 2688 KB Output is correct
12 Correct 5 ms 2816 KB Output is correct
13 Correct 6 ms 2944 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 6 ms 2944 KB Output is correct
16 Correct 6 ms 2944 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 Correct 3 ms 2688 KB Output is correct
21 Incorrect 3 ms 2688 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 10232 KB Output is correct
2 Correct 54 ms 10020 KB Output is correct
3 Correct 45 ms 8824 KB Output is correct
4 Correct 11 ms 3712 KB Output is correct
5 Correct 9 ms 3328 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 29 ms 5880 KB Output is correct
9 Correct 36 ms 7680 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 56 ms 8184 KB Output is correct
12 Correct 56 ms 9208 KB Output is correct
13 Correct 4 ms 2688 KB Output is correct
14 Correct 4 ms 2816 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
16 Correct 5 ms 2816 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 5 ms 2816 KB Output is correct
19 Correct 4 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 4 ms 2688 KB Output is correct
24 Correct 4 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 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 3 ms 2688 KB Output is correct
33 Correct 3 ms 2688 KB Output is correct
34 Correct 3 ms 2688 KB Output is correct
35 Correct 4 ms 2688 KB Output is correct
36 Correct 4 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 3 ms 2688 KB Output is correct
40 Correct 4 ms 2688 KB Output is correct
41 Incorrect 3 ms 2688 KB Output isn't correct
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 10232 KB Output is correct
2 Correct 54 ms 10020 KB Output is correct
3 Correct 45 ms 8824 KB Output is correct
4 Correct 11 ms 3712 KB Output is correct
5 Correct 9 ms 3328 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 29 ms 5880 KB Output is correct
9 Correct 36 ms 7680 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 56 ms 8184 KB Output is correct
12 Correct 56 ms 9208 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 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 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 2816 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Incorrect 3 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -