Submission #223116

# Submission time Handle Problem Language Result Execution time Memory
223116 2020-04-14T19:32:09 Z infinite_iq Dreaming (IOI13_dreaming) C++14
14 / 100
107 ms 17396 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 } ) ;
                }
        		if ( mn.se == 1e9 ) while ( 1 ) { }
                trees .pb ( mn ) ;
        }
        sort ( trees.begin() , trees.end() ) ;
        for ( int i = 0 ; i < (int)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 ;
  	//	if ( nodes.size() != n ) while ( 1 ) { }
        for ( auto u : nodes ) mx = max ( mx , dpdn[u] + dpup[u] ) ;
        return mx ;
}
# Verdict Execution time Memory Grader output
1 Correct 83 ms 15732 KB Output is correct
2 Correct 92 ms 17396 KB Output is correct
3 Correct 55 ms 11892 KB Output is correct
4 Correct 15 ms 4352 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 23 ms 6016 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 39 ms 7416 KB Output is correct
9 Correct 60 ms 10104 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 86 ms 11896 KB Output is correct
12 Correct 107 ms 14832 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 15732 KB Output is correct
2 Correct 92 ms 17396 KB Output is correct
3 Correct 55 ms 11892 KB Output is correct
4 Correct 15 ms 4352 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 23 ms 6016 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 39 ms 7416 KB Output is correct
9 Correct 60 ms 10104 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 86 ms 11896 KB Output is correct
12 Correct 107 ms 14832 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 6 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 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 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 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 83 ms 15732 KB Output is correct
2 Correct 92 ms 17396 KB Output is correct
3 Correct 55 ms 11892 KB Output is correct
4 Correct 15 ms 4352 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 23 ms 6016 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 39 ms 7416 KB Output is correct
9 Correct 60 ms 10104 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 86 ms 11896 KB Output is correct
12 Correct 107 ms 14832 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 6 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 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 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 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 8824 KB Output is correct
2 Incorrect 39 ms 8308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 83 ms 15732 KB Output is correct
2 Correct 92 ms 17396 KB Output is correct
3 Correct 55 ms 11892 KB Output is correct
4 Correct 15 ms 4352 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 23 ms 6016 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 39 ms 7416 KB Output is correct
9 Correct 60 ms 10104 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 86 ms 11896 KB Output is correct
12 Correct 107 ms 14832 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 6 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 7 ms 2864 KB Output is correct
19 Correct 8 ms 2944 KB Output is correct
20 Correct 6 ms 2816 KB Output is correct
21 Correct 7 ms 2816 KB Output is correct
22 Correct 9 ms 2992 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 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 83 ms 15732 KB Output is correct
2 Correct 92 ms 17396 KB Output is correct
3 Correct 55 ms 11892 KB Output is correct
4 Correct 15 ms 4352 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 23 ms 6016 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 39 ms 7416 KB Output is correct
9 Correct 60 ms 10104 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 86 ms 11896 KB Output is correct
12 Correct 107 ms 14832 KB Output is correct
13 Correct 7 ms 2816 KB Output is correct
14 Correct 6 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 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 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 Incorrect 6 ms 2688 KB Output isn't correct
29 Halted 0 ms 0 KB -