답안 #553904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
553904 2022-04-27T09:39:23 Z elazarkoren 꿈 (IOI13_dreaming) C++17
14 / 100
51 ms 65536 KB
#include "dreaming.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int MAX_N = 1e5 + 5;

vii tree[MAX_N];

bitset<MAX_N> visited;

pii DfsFar(int node, int parent, int d) {
    visited[node] = true;
    pii p = {d, node};
    for (auto [neighbor, w] : tree[node]) {
        if (neighbor != parent) {
            chkmax(p, DfsFar(neighbor, node, d + w));
        }
    }
    return p;
}

bool DfsPath(int node, int parent, int end, vii &path) {
    if (node == end) {
        path.push_back({node, 0});
        return true;
    }
    for (auto [neighbor, w] : tree[node]) {
        if (neighbor != parent && DfsPath(neighbor, node, end, path)) {
            path.push_back({node, w});
            return true;
        }
    }
}

int ans = 0;

int FindRadius(int node) {
    int v = DfsFar(node, -1, 0).y;
    auto [diameter, u] = DfsFar(v, -1, 0);
    int x = diameter;
    int dist = 0;
    vii path;
    DfsPath(v, -1, u, path);
    for (auto [node, w] : path) {
        chkmin(x, max(dist, diameter - dist));
        dist += w;
    }
    chkmax(ans, diameter);
    return x;
}

int travelTime(int n, int m, int l, int a[], int b[], int t[]) {
    for (int i = 0; i < m; i++) {
        tree[a[i]].push_back({b[i], t[i]});
        tree[b[i]].push_back({a[i], t[i]});
    }
    int s = 0;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            s += FindRadius(i) + l;
        }
    }
    chkmax(ans, s - l);
    return ans;
}

Compilation message

dreaming.cpp: In function 'bool DfsPath(int, int, int, vii&)':
dreaming.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 14820 KB Output is correct
2 Correct 46 ms 15972 KB Output is correct
3 Correct 30 ms 11532 KB Output is correct
4 Correct 8 ms 4612 KB Output is correct
5 Correct 6 ms 3668 KB Output is correct
6 Correct 13 ms 5716 KB Output is correct
7 Correct 2 ms 2656 KB Output is correct
8 Correct 25 ms 7120 KB Output is correct
9 Correct 30 ms 9244 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 40 ms 11140 KB Output is correct
12 Correct 50 ms 13676 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 14820 KB Output is correct
2 Correct 46 ms 15972 KB Output is correct
3 Correct 30 ms 11532 KB Output is correct
4 Correct 8 ms 4612 KB Output is correct
5 Correct 6 ms 3668 KB Output is correct
6 Correct 13 ms 5716 KB Output is correct
7 Correct 2 ms 2656 KB Output is correct
8 Correct 25 ms 7120 KB Output is correct
9 Correct 30 ms 9244 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 40 ms 11140 KB Output is correct
12 Correct 50 ms 13676 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Runtime error 34 ms 65536 KB Execution killed with signal 9
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 4932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 14820 KB Output is correct
2 Correct 46 ms 15972 KB Output is correct
3 Correct 30 ms 11532 KB Output is correct
4 Correct 8 ms 4612 KB Output is correct
5 Correct 6 ms 3668 KB Output is correct
6 Correct 13 ms 5716 KB Output is correct
7 Correct 2 ms 2656 KB Output is correct
8 Correct 25 ms 7120 KB Output is correct
9 Correct 30 ms 9244 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 40 ms 11140 KB Output is correct
12 Correct 50 ms 13676 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Runtime error 34 ms 65536 KB Execution killed with signal 9
15 Halted 0 ms 0 KB -