Submission #777899

# Submission time Handle Problem Language Result Execution time Memory
777899 2023-07-09T22:03:47 Z teokakabadze Dreaming (IOI13_dreaming) C++17
18 / 100
32 ms 14284 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
#define n 200005
#define pb push_back
#define f first
#define s second
#define pii pair<int, int>

int mn, dp[n], b[n], d[n];
bool f[n];
vector<pii> v[n];

void dfs(int u, int p)
{
    f[u] = 1;
    for(auto x : v[u])
    if(x.f != p)
    {
        dfs(x.f, u);
        if(dp[x.f] + x.s >= dp[u])
        {
            d[u] = dp[u];
            b[u] = x.f;
            dp[u] = dp[x.f] + x.s;
        }
        else d[u] = max(d[u], dp[x.f] + x.s);
    }
}
void dfs1(int u, int p, int k)
{
    if(k >= dp[u]) b[u] = -1, dp[u] = k;
    mn = min(mn, dp[u]);
    for(auto x : v[u])
    if(x.f != p)
    {
        if(b[u] == x.f) dfs1(x.f, u, max(d[u], k) + x.s);
        else dfs1(x.f, u, dp[u] + x.s);
    }
}

int travelTime(int N, int M, int L, int A[], int B[], int T[])
{
    int i;
    vector<int> c;
    for(i = 0; i < M; i++)
    {
        v[A[i]].pb({B[i], T[i]});
        v[B[i]].pb({A[i], T[i]});
    }
    for(i = 0; i < N; i++)
    if(!f[i])
    {
        dfs(i, -1);
        mn = dp[i];
        dfs1(i, -1, 0);
        //cout << i << ' ' << mn << '\n';
        c.pb(mn);
    }
    sort(c.rbegin(), c.rend());
    if(c.size() == 1) return c[0];
    if(c.size() == 2) return L + c[0] + c[1];
    return max(c[0] + c[1] + L, 2 * L + c[1] + c[2]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 14284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 14284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 9160 KB Output is correct
2 Correct 15 ms 9076 KB Output is correct
3 Correct 15 ms 9092 KB Output is correct
4 Correct 16 ms 9088 KB Output is correct
5 Correct 22 ms 9084 KB Output is correct
6 Correct 16 ms 9560 KB Output is correct
7 Correct 17 ms 9304 KB Output is correct
8 Correct 17 ms 8988 KB Output is correct
9 Correct 16 ms 8996 KB Output is correct
10 Correct 15 ms 9296 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 5 ms 6736 KB Output is correct
13 Correct 5 ms 6812 KB Output is correct
14 Correct 5 ms 6736 KB Output is correct
15 Correct 5 ms 6736 KB Output is correct
16 Correct 5 ms 6800 KB Output is correct
17 Correct 5 ms 6548 KB Output is correct
18 Correct 5 ms 6864 KB Output is correct
19 Correct 5 ms 6736 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 3 ms 5012 KB Output is correct
23 Correct 5 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 14284 KB Output isn't correct
2 Halted 0 ms 0 KB -