Submission #728529

# Submission time Handle Problem Language Result Execution time Memory
728529 2023-04-22T15:03:09 Z Rasoul006 Dreaming (IOI13_dreaming) C++17
0 / 100
77 ms 16248 KB
#include "dreaming.h"

#include <bits/stdc++.h>

#define endl "\n"

#define F first

#define S second

#define pb push_back

typedef long long ll;

using namespace std;

const int N = 1e5+5;

const long long oo = 1e18 ;

vector <pair <ll,ll>> v[N] ;

ll n , m , ans , best , mx , dis[N] , len ;

bool vis[N] ;

pair <ll,ll> dfs (ll u , ll p)
{
    pair <ll,ll> ret = {0 , u} ;

    for (auto it : v[u])
    {
        if (it.F == p) continue ;

        pair <ll,ll> p = dfs(it.F , u) ;

        p.F += it.S ;

        ret = max(ret , p) ;
    }

    best = min(best , max(len - ret.F , ret.F) ) ;

    return ret ;
}

ll p1 , p2 ;

ll get (ll p)
{
    p1 = dfs(p , p).S ;
    p2 = dfs(p1 , p1).S ;
    len = dfs(p1 , p1).F ;

    best = oo ;

    dfs(p1 , p1) ;

    return best ;
}


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++)
    {
        v[B[i]].pb({A[i] , T[i]});
        v[A[i]].pb({B[i] , T[i]});
    }

    ans += get(1) ;

    ll bans = len ;

    for (int i = 1 ; i<=n ; i++)
    {
        if (!vis[i])
        {
            ans += get(i) ;
            break ;
        }
    }

    bans = max(bans , len) ;

    return max(bans , ans + L) ;
}
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 16248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 16248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 5292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 16248 KB Output isn't correct
2 Halted 0 ms 0 KB -