답안 #240428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240428 2020-06-19T15:57:13 Z oscarsierra12 꿈 (IOI13_dreaming) C++14
47 / 100
473 ms 29812 KB
#include "dreaming.h"
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <set>
#include <deque>
#include <utility>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <limits.h>

using namespace std ;
const int N = 1e5+2;

#define  ff    first
#define  ss    second
#define  pb    push_back

vector <int> ans, cur ;
int best = 0 ;
int visit[N];
vector <pair<int,int> > G[N] ;
int node = 0 ;
map <pair<int,int>, int > dis ;

void fnd ( int u, int p, int d, int flag ) {
    cur.push_back ( u ) ;
    visit[u] = 1;
    for ( auto v:G[u] ) {
        if ( v.ff == p ) continue ;
        fnd ( v.ff, u, d + v.ss, flag ) ;
    }
    if ( d >= best ) {
        best = d;
        if ( flag && u == node ) ans = cur ;
        if ( !flag ) node = u ;
    }
    cur.pop_back() ;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for ( int i = 0 ; i < M ; ++i ) G[A[i]].pb ( make_pair (B[i], T[i]) ), G[B[i]].pb ( make_pair(A[i], T[i]) ), dis[make_pair(A[i], B[i])] = dis[make_pair(B[i],A[i])] = T[i] ;
    vector <int> toAn ;
    int ot = 0 ;
    for ( int i = 0 ; i < N ; ++i ) {
        if ( visit[i] ) continue;
        best = 0 ;
        fnd ( i, -1, 0,0 ) ;
        best = 0 ;
        int nod = node ;
        fnd ( nod, -1, 0,0 ) ;
        fnd ( nod,-1,0,1) ;
        vector <int> diLeft, diRg ;
        diLeft.push_back (0) ;
        diRg.push_back (0) ;
        int lft = 0, rg = 0 ;
        for ( int j = 1 ; j < ans.size() ; ++j ) {
            lft += dis [ make_pair(ans[j], ans[j-1]) ] ;
            diLeft.push_back(lft) ;
        }
        ot = max ( ot, lft ) ;
        int sz = ans.size() ;
        for ( int j = sz-2 ; j >= 0 ; --j ) {
            rg += dis[make_pair(ans[j], ans[j+1])] ;
            diRg.push_back (rg) ;
        }
        reverse ( diRg.begin(), diRg.end() ) ;
        int an = INT_MAX ;
        for ( int i = 0 ; i < ans.size() ; ++i ) {
            an = min ( an, max (diRg[i], diLeft[i]) ) ;
        }
        toAn.push_back ( an );
    }
    sort ( toAn.begin(), toAn.end() ) ;
    int mx = toAn.back() + L ;
    toAn.pop_back() ;
    mx += toAn.back() ;
    mx = max ( mx, ot ) ;
    int scP = toAn.back() + 2 * L ;
    if ( toAn.size() == 1 ) return mx ;
    toAn.pop_back() ;
    scP += toAn.back() ;
    return max ( scP, mx ) ;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:67:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int j = 1 ; j < ans.size() ; ++j ) {
                           ~~^~~~~~~~~~~~
dreaming.cpp:79:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i = 0 ; i < ans.size() ; ++i ) {
                           ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 26096 KB Output is correct
2 Correct 276 ms 27124 KB Output is correct
3 Correct 159 ms 18804 KB Output is correct
4 Correct 27 ms 6272 KB Output is correct
5 Correct 25 ms 4992 KB Output is correct
6 Correct 45 ms 8184 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 113 ms 12232 KB Output is correct
9 Correct 155 ms 15520 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 352 ms 19828 KB Output is correct
12 Correct 306 ms 23412 KB Output is correct
13 Correct 7 ms 2944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 26096 KB Output is correct
2 Correct 276 ms 27124 KB Output is correct
3 Correct 159 ms 18804 KB Output is correct
4 Correct 27 ms 6272 KB Output is correct
5 Correct 25 ms 4992 KB Output is correct
6 Correct 45 ms 8184 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 113 ms 12232 KB Output is correct
9 Correct 155 ms 15520 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 352 ms 19828 KB Output is correct
12 Correct 306 ms 23412 KB Output is correct
13 Correct 7 ms 2944 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2664 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 7 ms 2688 KB Output is correct
23 Correct 6 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 6 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 6 ms 2688 KB Output is correct
32 Correct 6 ms 2688 KB Output is correct
33 Correct 6 ms 2688 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 26096 KB Output is correct
2 Correct 276 ms 27124 KB Output is correct
3 Correct 159 ms 18804 KB Output is correct
4 Correct 27 ms 6272 KB Output is correct
5 Correct 25 ms 4992 KB Output is correct
6 Correct 45 ms 8184 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 113 ms 12232 KB Output is correct
9 Correct 155 ms 15520 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 352 ms 19828 KB Output is correct
12 Correct 306 ms 23412 KB Output is correct
13 Correct 7 ms 2944 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2664 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 7 ms 2688 KB Output is correct
23 Correct 6 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 6 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 6 ms 2688 KB Output is correct
32 Correct 6 ms 2688 KB Output is correct
33 Correct 6 ms 2688 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
39 Correct 281 ms 27148 KB Output is correct
40 Correct 282 ms 27120 KB Output is correct
41 Correct 225 ms 18804 KB Output is correct
42 Correct 29 ms 6272 KB Output is correct
43 Correct 6 ms 2560 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 6 ms 2688 KB Output is correct
47 Correct 7 ms 2688 KB Output is correct
48 Correct 6 ms 2688 KB Output is correct
49 Correct 6 ms 2560 KB Output is correct
50 Correct 7 ms 2688 KB Output is correct
51 Correct 6 ms 2688 KB Output is correct
52 Correct 7 ms 2688 KB Output is correct
53 Correct 7 ms 2688 KB Output is correct
54 Correct 6 ms 2688 KB Output is correct
55 Correct 6 ms 2688 KB Output is correct
56 Correct 6 ms 2688 KB Output is correct
57 Correct 289 ms 22140 KB Output is correct
58 Correct 299 ms 22140 KB Output is correct
59 Correct 294 ms 22136 KB Output is correct
60 Correct 298 ms 22136 KB Output is correct
61 Correct 305 ms 22300 KB Output is correct
62 Correct 313 ms 22252 KB Output is correct
63 Correct 291 ms 21880 KB Output is correct
64 Correct 278 ms 21860 KB Output is correct
65 Correct 287 ms 22008 KB Output is correct
66 Correct 291 ms 22264 KB Output is correct
67 Correct 324 ms 22136 KB Output is correct
68 Correct 297 ms 22264 KB Output is correct
69 Correct 333 ms 22392 KB Output is correct
70 Correct 307 ms 22404 KB Output is correct
71 Correct 6 ms 2688 KB Output is correct
72 Correct 9 ms 3328 KB Output is correct
73 Correct 10 ms 3200 KB Output is correct
74 Correct 9 ms 3200 KB Output is correct
75 Correct 9 ms 3200 KB Output is correct
76 Correct 9 ms 3200 KB Output is correct
77 Correct 10 ms 3328 KB Output is correct
78 Correct 9 ms 3328 KB Output is correct
79 Correct 9 ms 3328 KB Output is correct
80 Correct 284 ms 22136 KB Output is correct
81 Correct 293 ms 22116 KB Output is correct
82 Correct 303 ms 22136 KB Output is correct
83 Correct 381 ms 22180 KB Output is correct
84 Correct 9 ms 3072 KB Output is correct
85 Correct 8 ms 3072 KB Output is correct
86 Correct 9 ms 3200 KB Output is correct
87 Correct 10 ms 3200 KB Output is correct
88 Correct 9 ms 3200 KB Output is correct
89 Correct 9 ms 3200 KB Output is correct
90 Correct 9 ms 3200 KB Output is correct
91 Correct 9 ms 3200 KB Output is correct
92 Correct 9 ms 3200 KB Output is correct
93 Correct 9 ms 3200 KB Output is correct
94 Correct 6 ms 2688 KB Output is correct
95 Correct 6 ms 2688 KB Output is correct
96 Correct 6 ms 2656 KB Output is correct
97 Correct 6 ms 2816 KB Output is correct
98 Correct 6 ms 2688 KB Output is correct
99 Correct 6 ms 2688 KB Output is correct
100 Correct 6 ms 2688 KB Output is correct
101 Correct 6 ms 2688 KB Output is correct
102 Correct 6 ms 2688 KB Output is correct
103 Correct 6 ms 2688 KB Output is correct
104 Correct 23 ms 4992 KB Output is correct
105 Correct 44 ms 8184 KB Output is correct
106 Correct 6 ms 2816 KB Output is correct
107 Correct 114 ms 12220 KB Output is correct
108 Correct 164 ms 15348 KB Output is correct
109 Correct 7 ms 2816 KB Output is correct
110 Correct 258 ms 19828 KB Output is correct
111 Correct 299 ms 23408 KB Output is correct
112 Correct 7 ms 2944 KB Output is correct
113 Correct 473 ms 29812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 9612 KB Output is correct
2 Correct 87 ms 9720 KB Output is correct
3 Correct 101 ms 9592 KB Output is correct
4 Correct 92 ms 9724 KB Output is correct
5 Correct 83 ms 9592 KB Output is correct
6 Correct 90 ms 10356 KB Output is correct
7 Correct 93 ms 10104 KB Output is correct
8 Correct 82 ms 9592 KB Output is correct
9 Correct 126 ms 9464 KB Output is correct
10 Correct 87 ms 9848 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 21 ms 3708 KB Output is correct
13 Correct 20 ms 3840 KB Output is correct
14 Correct 19 ms 3708 KB Output is correct
15 Correct 20 ms 3712 KB Output is correct
16 Correct 19 ms 3716 KB Output is correct
17 Correct 19 ms 3708 KB Output is correct
18 Correct 20 ms 3836 KB Output is correct
19 Correct 19 ms 3708 KB Output is correct
20 Incorrect 6 ms 2688 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 26096 KB Output is correct
2 Correct 276 ms 27124 KB Output is correct
3 Correct 159 ms 18804 KB Output is correct
4 Correct 27 ms 6272 KB Output is correct
5 Correct 25 ms 4992 KB Output is correct
6 Correct 45 ms 8184 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 113 ms 12232 KB Output is correct
9 Correct 155 ms 15520 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 352 ms 19828 KB Output is correct
12 Correct 306 ms 23412 KB Output is correct
13 Correct 7 ms 2944 KB Output is correct
14 Correct 7 ms 2816 KB Output is correct
15 Correct 8 ms 2944 KB Output is correct
16 Correct 9 ms 3200 KB Output is correct
17 Correct 8 ms 2816 KB Output is correct
18 Correct 9 ms 2944 KB Output is correct
19 Correct 9 ms 3200 KB Output is correct
20 Correct 7 ms 2816 KB Output is correct
21 Correct 8 ms 3072 KB Output is correct
22 Correct 9 ms 3200 KB Output is correct
23 Correct 7 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 7 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 6 ms 2688 KB Output is correct
32 Correct 6 ms 2688 KB Output is correct
33 Correct 6 ms 2688 KB Output is correct
34 Correct 7 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 7 ms 2816 KB Output is correct
38 Correct 6 ms 2724 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Incorrect 6 ms 2688 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 26096 KB Output is correct
2 Correct 276 ms 27124 KB Output is correct
3 Correct 159 ms 18804 KB Output is correct
4 Correct 27 ms 6272 KB Output is correct
5 Correct 25 ms 4992 KB Output is correct
6 Correct 45 ms 8184 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 113 ms 12232 KB Output is correct
9 Correct 155 ms 15520 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 352 ms 19828 KB Output is correct
12 Correct 306 ms 23412 KB Output is correct
13 Correct 7 ms 2944 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2664 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 7 ms 2688 KB Output is correct
23 Correct 6 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 6 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 6 ms 2688 KB Output is correct
32 Correct 6 ms 2688 KB Output is correct
33 Correct 6 ms 2688 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
39 Correct 281 ms 27148 KB Output is correct
40 Correct 282 ms 27120 KB Output is correct
41 Correct 225 ms 18804 KB Output is correct
42 Correct 29 ms 6272 KB Output is correct
43 Correct 6 ms 2560 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 6 ms 2688 KB Output is correct
47 Correct 7 ms 2688 KB Output is correct
48 Correct 6 ms 2688 KB Output is correct
49 Correct 6 ms 2560 KB Output is correct
50 Correct 7 ms 2688 KB Output is correct
51 Correct 6 ms 2688 KB Output is correct
52 Correct 7 ms 2688 KB Output is correct
53 Correct 7 ms 2688 KB Output is correct
54 Correct 6 ms 2688 KB Output is correct
55 Correct 6 ms 2688 KB Output is correct
56 Correct 6 ms 2688 KB Output is correct
57 Correct 289 ms 22140 KB Output is correct
58 Correct 299 ms 22140 KB Output is correct
59 Correct 294 ms 22136 KB Output is correct
60 Correct 298 ms 22136 KB Output is correct
61 Correct 305 ms 22300 KB Output is correct
62 Correct 313 ms 22252 KB Output is correct
63 Correct 291 ms 21880 KB Output is correct
64 Correct 278 ms 21860 KB Output is correct
65 Correct 287 ms 22008 KB Output is correct
66 Correct 291 ms 22264 KB Output is correct
67 Correct 324 ms 22136 KB Output is correct
68 Correct 297 ms 22264 KB Output is correct
69 Correct 333 ms 22392 KB Output is correct
70 Correct 307 ms 22404 KB Output is correct
71 Correct 6 ms 2688 KB Output is correct
72 Correct 9 ms 3328 KB Output is correct
73 Correct 10 ms 3200 KB Output is correct
74 Correct 9 ms 3200 KB Output is correct
75 Correct 9 ms 3200 KB Output is correct
76 Correct 9 ms 3200 KB Output is correct
77 Correct 10 ms 3328 KB Output is correct
78 Correct 9 ms 3328 KB Output is correct
79 Correct 9 ms 3328 KB Output is correct
80 Correct 284 ms 22136 KB Output is correct
81 Correct 293 ms 22116 KB Output is correct
82 Correct 303 ms 22136 KB Output is correct
83 Correct 381 ms 22180 KB Output is correct
84 Correct 9 ms 3072 KB Output is correct
85 Correct 8 ms 3072 KB Output is correct
86 Correct 9 ms 3200 KB Output is correct
87 Correct 10 ms 3200 KB Output is correct
88 Correct 9 ms 3200 KB Output is correct
89 Correct 9 ms 3200 KB Output is correct
90 Correct 9 ms 3200 KB Output is correct
91 Correct 9 ms 3200 KB Output is correct
92 Correct 9 ms 3200 KB Output is correct
93 Correct 9 ms 3200 KB Output is correct
94 Correct 6 ms 2688 KB Output is correct
95 Correct 6 ms 2688 KB Output is correct
96 Correct 6 ms 2656 KB Output is correct
97 Correct 6 ms 2816 KB Output is correct
98 Correct 6 ms 2688 KB Output is correct
99 Correct 6 ms 2688 KB Output is correct
100 Correct 6 ms 2688 KB Output is correct
101 Correct 6 ms 2688 KB Output is correct
102 Correct 6 ms 2688 KB Output is correct
103 Correct 6 ms 2688 KB Output is correct
104 Correct 23 ms 4992 KB Output is correct
105 Correct 44 ms 8184 KB Output is correct
106 Correct 6 ms 2816 KB Output is correct
107 Correct 114 ms 12220 KB Output is correct
108 Correct 164 ms 15348 KB Output is correct
109 Correct 7 ms 2816 KB Output is correct
110 Correct 258 ms 19828 KB Output is correct
111 Correct 299 ms 23408 KB Output is correct
112 Correct 7 ms 2944 KB Output is correct
113 Correct 473 ms 29812 KB Output is correct
114 Correct 85 ms 9612 KB Output is correct
115 Correct 87 ms 9720 KB Output is correct
116 Correct 101 ms 9592 KB Output is correct
117 Correct 92 ms 9724 KB Output is correct
118 Correct 83 ms 9592 KB Output is correct
119 Correct 90 ms 10356 KB Output is correct
120 Correct 93 ms 10104 KB Output is correct
121 Correct 82 ms 9592 KB Output is correct
122 Correct 126 ms 9464 KB Output is correct
123 Correct 87 ms 9848 KB Output is correct
124 Correct 6 ms 2688 KB Output is correct
125 Correct 21 ms 3708 KB Output is correct
126 Correct 20 ms 3840 KB Output is correct
127 Correct 19 ms 3708 KB Output is correct
128 Correct 20 ms 3712 KB Output is correct
129 Correct 19 ms 3716 KB Output is correct
130 Correct 19 ms 3708 KB Output is correct
131 Correct 20 ms 3836 KB Output is correct
132 Correct 19 ms 3708 KB Output is correct
133 Incorrect 6 ms 2688 KB Output isn't correct
134 Halted 0 ms 0 KB -