답안 #223112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223112 2020-04-14T19:24:00 Z infinite_iq 꿈 (IOI13_dreaming) C++14
14 / 100
112 ms 18548 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 547
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll inf=1e18;
const ld pai=acos(-1);
#include "dreaming.h"
int n , m ;
vpi v[100009] , trees;
int done[100009];
int dpdn[100009] , dpup[100009] ;
vi nodes;
void who ( int node , int p ) {
        done [ node ] = 1 ;
        nodes.pb ( node ) ;
        for ( auto u : v [ node ] ) {
                if ( u.fi == p ) C ;
                who ( u.fi , node ) ;
        }
}
void dfsdn ( int node , int p ) {
        for ( auto u : v[node] ) {
                if ( u.fi == p ) C ;
                dfsdn ( u.fi , node ) ;
                dpdn[node] = max ( dpdn[node] , dpdn[u.fi] + u.se ) ;
        }
}
void dfsup ( int node , int p ) {
        pi mx1 , mx2 ;
        mx1 = mx2 = { -1 , -1 } ;
        for ( auto U : v[node] ) {
                int u = U.fi ;
                int x = U.se ;
                if ( u == p ) C ;
                pi ret = { dpdn[u] + x , u } ;
                if ( ret.fi > mx1.fi ) {
                        swap ( mx1 , mx2 ) ;
                        mx1 = ret ;
                }
                else mx2 = max ( mx2 , ret ) ;
        }
        for ( auto U : v[node] ) {
                int u = U.fi ;
                int x = U.se ;
                if ( u == p ) C ;
                int MX= dpup[node];
                if ( mx1.se != u ) MX = max ( MX , mx1.fi ) ;
                else MX = max ( MX , mx2.fi ) ;
                dpup[u] = MX + x ;
                dfsup( u , node ) ;
        }
}
void fill ( int node ) {
        nodes.clear() ;
        who ( node , node ) ;
        for ( auto u : nodes ) dpdn[u] = dpup[u] = 0 ;
        dfsdn ( node , node ) ;
        dfsup ( node , node ) ;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
        n = N , m = M ;
        for ( int i = 0 ; i < m ; i ++ ) {
                int a = A[i] ;
                int b = B[i] ;
                int c = T[i] ;
                v[a].pb ( { b , c } ) ;
                v[b].pb ( { a , c } ) ;
        }
        for ( int i = 1 ; i < n ; i ++ ) {
                if ( done [i] ) C ;
                fill ( i ) ;
                pi mn = { 1e9 , 1e9 } ;
                for ( auto u : nodes ) {
                        mn = min ( mn , { max ( dpdn[u] , dpup[u] ) , u } ) ;
                }
                trees .pb ( mn ) ;
        }
        sort ( trees.begin() , trees.end() ) ;
        for ( int i = 0 ; i < trees.size() - 1 ; i ++ ) {
                int a = trees[i].se;
                int b = trees.back().se;
                v[a] .pb ( { b , L } ) ;
                v[b] .pb ( { a , L } ) ;
        }
        fill ( 0 ) ;
        int mx = 0 ;
        for ( auto u : nodes ) mx = max ( mx , dpdn[u] + dpup[u] ) ;
        return mx ;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:100:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i = 0 ; i < trees.size() - 1 ; i ++ ) {
                           ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 17012 KB Output is correct
2 Correct 84 ms 18548 KB Output is correct
3 Correct 57 ms 12916 KB Output is correct
4 Correct 15 ms 4608 KB Output is correct
5 Correct 13 ms 3840 KB Output is correct
6 Correct 21 ms 6272 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 39 ms 7928 KB Output is correct
9 Correct 51 ms 10744 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 87 ms 13048 KB Output is correct
12 Correct 112 ms 15980 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 17012 KB Output is correct
2 Correct 84 ms 18548 KB Output is correct
3 Correct 57 ms 12916 KB Output is correct
4 Correct 15 ms 4608 KB Output is correct
5 Correct 13 ms 3840 KB Output is correct
6 Correct 21 ms 6272 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 39 ms 7928 KB Output is correct
9 Correct 51 ms 10744 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 87 ms 13048 KB Output is correct
12 Correct 112 ms 15980 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 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 6 ms 2816 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 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 6 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 17012 KB Output is correct
2 Correct 84 ms 18548 KB Output is correct
3 Correct 57 ms 12916 KB Output is correct
4 Correct 15 ms 4608 KB Output is correct
5 Correct 13 ms 3840 KB Output is correct
6 Correct 21 ms 6272 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 39 ms 7928 KB Output is correct
9 Correct 51 ms 10744 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 87 ms 13048 KB Output is correct
12 Correct 112 ms 15980 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 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 6 ms 2816 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 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 6 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 9328 KB Output is correct
2 Incorrect 43 ms 8820 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 17012 KB Output is correct
2 Correct 84 ms 18548 KB Output is correct
3 Correct 57 ms 12916 KB Output is correct
4 Correct 15 ms 4608 KB Output is correct
5 Correct 13 ms 3840 KB Output is correct
6 Correct 21 ms 6272 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 39 ms 7928 KB Output is correct
9 Correct 51 ms 10744 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 87 ms 13048 KB Output is correct
12 Correct 112 ms 15980 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 7 ms 2816 KB Output is correct
15 Correct 7 ms 2816 KB Output is correct
16 Correct 8 ms 2944 KB Output is correct
17 Correct 7 ms 2816 KB Output is correct
18 Correct 8 ms 2816 KB Output is correct
19 Correct 8 ms 2944 KB Output is correct
20 Correct 7 ms 2816 KB Output is correct
21 Correct 7 ms 2816 KB Output is correct
22 Correct 8 ms 2944 KB Output is correct
23 Correct 6 ms 2688 KB Output is correct
24 Correct 7 ms 2688 KB Output is correct
25 Correct 7 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 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 17012 KB Output is correct
2 Correct 84 ms 18548 KB Output is correct
3 Correct 57 ms 12916 KB Output is correct
4 Correct 15 ms 4608 KB Output is correct
5 Correct 13 ms 3840 KB Output is correct
6 Correct 21 ms 6272 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 39 ms 7928 KB Output is correct
9 Correct 51 ms 10744 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 87 ms 13048 KB Output is correct
12 Correct 112 ms 15980 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 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 6 ms 2816 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 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 6 ms 2688 KB Output is correct
27 Correct 6 ms 2688 KB Output is correct
28 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -