답안 #881829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
881829 2023-12-02T03:26:17 Z _KuroNeko_ 꿈 (IOI13_dreaming) C++17
18 / 100
30 ms 13392 KB
#include<bits/stdc++.h>
#include "dreaming.h"
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vdb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef set<int> si;
typedef set<long long> sl;
typedef set<double> sdb;
typedef set<string> ss;
typedef set<char> sc;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ftb(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define ft(i, a, b) for (int i = a, _b = b; i < _b; ++i)
#define fgb(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define fg(i, a, b) for (int i = a, _b = b; i > _b; --i)
#define endl "\n"
const int N = 1e5;
vector<pii> adj[N + 1];
int color[N + 1];
ll up[N + 1];
ll down[N + 1];
vl ans(N + 1, 1e16);
void dfsDown(int node) {
    for (pii it : adj[node]) {
        if (color[it.first] == 0) {
            color[it.first] = color[node];
            dfsDown(it.first);
            down[node] = max(down[node], down[it.first] + it.second);
        }
    }
}
void dfsUp(int node, int parent) {
    ll mx1 = -1, mx2 = -1;
    for (pii it : adj[node]) {
        if (it.first != parent) {
            if (down[it.first] + it.second > mx1) {
                mx2 = mx1;
                mx1 = down[it.first] + it.second;
            }
            else {
                mx2 = max(mx2, down[it.first] + it.second);
            }
        }
    }
    for (pii it : adj[node]) {
        if (it.first != parent) {
            up[it.first] = up[node] + it.second;
            if (down[it.first] + it.second != mx1) {
                up[it.first] = max(up[it.first], mx1 + it.second);
            }
            else {
                up[it.first] = max(up[it.first], mx2 + it.second);
            }
            dfsUp(it.first, node);
        }
    }
}
int travelTime(int n, int m, int l, int a[], int b[], int t[]) {
    ft(i, 0, m) {
        adj[a[i]].push_back({ b[i],t[i] });
        adj[b[i]].push_back({ a[i],t[i] });
    }
    int num = 1;
    ft(i, 0, n) {
        if (color[i] == 0) {
            color[i] = num++;
            dfsDown(i);
            dfsUp(i, 0);
        }
    }
    ft(i, 0, n) {
        ans[color[i]] = min(ans[color[i]], max(down[i], up[i]));
    }
    vl temp;
    ft(i, 1, num) {
        temp.push_back(ans[i]);
    }
    sort(temp.rbegin(), temp.rend());
    if (temp.size() == 1) {
        return temp[0];
    }
    if (temp.size() == 2) {
        return temp[0] + temp[1] + l;
    }
    return max(temp[0] + temp[1] + l, temp[1] + temp[2] + 2 * l);
}
// int main() {
//     int n, m, l;
//     cin >> n >> m >> l;
//     int a[m], b[m], t[m];
//     ft(i, 0, m) {
//         cin >> a[i];
//     }
//     ft(i, 0, m) {
//         cin >> b[i];
//     }
//     ft(i, 0, m) {
//         cin >> t[i];
//     }
//     int kq = travelTime(n, m, l, a, b, t);
//     cout << kq;
// }
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 13392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 13392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 9248 KB Output is correct
2 Correct 26 ms 9576 KB Output is correct
3 Correct 18 ms 9440 KB Output is correct
4 Correct 17 ms 9592 KB Output is correct
5 Correct 16 ms 9432 KB Output is correct
6 Correct 16 ms 10204 KB Output is correct
7 Correct 16 ms 9756 KB Output is correct
8 Correct 15 ms 9428 KB Output is correct
9 Correct 14 ms 9604 KB Output is correct
10 Correct 20 ms 9652 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 4 ms 7636 KB Output is correct
13 Correct 4 ms 7636 KB Output is correct
14 Correct 4 ms 7636 KB Output is correct
15 Correct 4 ms 7724 KB Output is correct
16 Correct 4 ms 7636 KB Output is correct
17 Correct 4 ms 7636 KB Output is correct
18 Correct 6 ms 7892 KB Output is correct
19 Correct 4 ms 7636 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 4 ms 7636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 13392 KB Output isn't correct
2 Halted 0 ms 0 KB -