Submission #961030

# Submission time Handle Problem Language Result Execution time Memory
961030 2024-04-11T12:22:07 Z Gr1sen Dreaming (IOI13_dreaming) C++17
0 / 100
1000 ms 18572 KB
#include "dreaming.h"
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define F first
#define S second
#define vp vector<pi>
#define vvp vector<vp>

vi V;
vvp Adj;

struct point {
    int p = -1;
    int t = -1;
    int c = -1;
};

point oinkoink(int p, int dfp, int t) {
    if (Adj[p].size() == 0) return {p, 0, 0};
    if (Adj[p].size() == 1 && Adj[p][0].F == dfp) return {p, t, -1};
    point m;
    for (auto i : Adj[p]) {
        if (i.F == dfp) continue;
        point a = oinkoink(i.F, p, t+i.S);
        if (m.t >= a.t) continue;
        m = a;
        if (m.t > t*2 && m.c == -1) m.c = min(t+i.S, m.t-t+i.S);
    }
    return m;
}

pi oink(int p, int n) {
    int a = oinkoink(p, -1, 0).p;
    point k = oinkoink(a, -1, 0);
    return {k.c, k.t};
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    Adj.clear();
    Adj.resize(N);
    V.clear();
    V.resize(N, 0);
    int a, b, c, d;
    for (int i = 0; i < M; i++) {
        int a = A[i], b = B[i], t = T[i];
        Adj[a].push_back({b, t});
        Adj[b].push_back({a, t});
    }
    for (int i = 0; i < N; i++) {
        if (V[i]) continue;
        pi on = oink(i, N);
        int o = on.F;
        int d = max(d, on.S);
        if (o > a) {c = b; b = a; a = o; continue;}
        if (o > b) {c = b; b = o; continue;}
        if (o > c) {c = o; continue;}
    }
    int maks = d;
    maks = max(maks, a+b+L);
    maks = max(maks, b+L+L+c);
    return maks;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:50:18: warning: 'd' is used uninitialized in this function [-Wuninitialized]
   50 |     int a, b, c, d;
      |                  ^
dreaming.cpp:67:27: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |     maks = max(maks, b+L+L+c);
      |                      ~~~~~^~
dreaming.cpp:67:23: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |     maks = max(maks, b+L+L+c);
      |                      ~^~
dreaming.cpp:66:23: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |     maks = max(maks, a+b+L);
      |                      ~^~
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 18572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 18572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 5208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 18572 KB Time limit exceeded
2 Halted 0 ms 0 KB -