답안 #558546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
558546 2022-05-07T14:00:00 Z proma 자매 도시 (APIO20_swap) C++17
0 / 100
2000 ms 17240 KB
#include "swap.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n, m, used[N], flag;
vector <pair <int, int>> g[N];
vector <int> val;

void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
    n = N;
    m = M;
    for (int i = 0; i < M; i ++) {
        g[U[i]].push_back({V[i], W[i]});
        g[V[i]].push_back({U[i], W[i]});
        val.push_back(W[i]);
    }
    sort(val.begin(), val.end());
}

void dfs(int v, int p, int k, int x, int y) {
    used[v] = 1;
//    cerr << "v = " << v << endl;
    if (v != x and v != y and g[v].size() > 2) flag = 1;
    for (auto i: g[v]) {
        if (i.second > k or i.first == p) continue;
        if (used[i.first]) flag = 1;
        else dfs(i.first, v, k, x, y);
    }
}

int getMinimumFuelCapacity(int X, int Y) {
    int l = 0, r = m - 1, best = -1;
    while (l <= r) {
        int mid = (l + r) / 2;
//        cerr << "mid = " << mid << endl;
        flag = 0;
        memset(used, 0, sizeof(used));
        dfs(X, 0, val[mid], X, Y);
//        cerr << "used[Y] = " << used[Y] << endl;
//        cerr << "flag = " << flag << endl;
        if (used[Y] and flag) {
            best = val[mid];
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
    return best;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3028 KB Output is correct
2 Correct 3 ms 2928 KB Output is correct
3 Correct 2 ms 3036 KB Output is correct
4 Correct 3 ms 3028 KB Output is correct
5 Correct 4 ms 3064 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 3 ms 3156 KB Output is correct
9 Correct 102 ms 14404 KB Output is correct
10 Correct 200 ms 16228 KB Output is correct
11 Correct 223 ms 16360 KB Output is correct
12 Correct 327 ms 16468 KB Output is correct
13 Correct 746 ms 17240 KB Output is correct
14 Execution timed out 2077 ms 14816 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3028 KB Output is correct
2 Correct 3 ms 2928 KB Output is correct
3 Execution timed out 2060 ms 14284 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3028 KB Output is correct
2 Correct 3 ms 2928 KB Output is correct
3 Correct 2 ms 3036 KB Output is correct
4 Correct 3 ms 3028 KB Output is correct
5 Correct 4 ms 3064 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 3 ms 3156 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 3 ms 3028 KB Output is correct
11 Correct 3 ms 3156 KB Output is correct
12 Correct 4 ms 3036 KB Output is correct
13 Correct 4 ms 3028 KB Output is correct
14 Correct 4 ms 3028 KB Output is correct
15 Incorrect 4 ms 3028 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3028 KB Output is correct
2 Correct 3 ms 3028 KB Output is correct
3 Correct 3 ms 2928 KB Output is correct
4 Correct 2 ms 3036 KB Output is correct
5 Correct 3 ms 3028 KB Output is correct
6 Correct 4 ms 3064 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 3 ms 3156 KB Output is correct
9 Correct 3 ms 3156 KB Output is correct
10 Correct 102 ms 14404 KB Output is correct
11 Correct 200 ms 16228 KB Output is correct
12 Correct 223 ms 16360 KB Output is correct
13 Correct 327 ms 16468 KB Output is correct
14 Correct 746 ms 17240 KB Output is correct
15 Correct 3 ms 3028 KB Output is correct
16 Correct 3 ms 3156 KB Output is correct
17 Correct 4 ms 3036 KB Output is correct
18 Correct 4 ms 3028 KB Output is correct
19 Correct 4 ms 3028 KB Output is correct
20 Incorrect 4 ms 3028 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3028 KB Output is correct
2 Correct 3 ms 2928 KB Output is correct
3 Correct 2 ms 3036 KB Output is correct
4 Correct 3 ms 3028 KB Output is correct
5 Correct 4 ms 3064 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 3 ms 3156 KB Output is correct
9 Correct 102 ms 14404 KB Output is correct
10 Correct 200 ms 16228 KB Output is correct
11 Correct 223 ms 16360 KB Output is correct
12 Correct 327 ms 16468 KB Output is correct
13 Correct 746 ms 17240 KB Output is correct
14 Execution timed out 2077 ms 14816 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3028 KB Output is correct
2 Correct 3 ms 3028 KB Output is correct
3 Correct 3 ms 2928 KB Output is correct
4 Correct 2 ms 3036 KB Output is correct
5 Correct 3 ms 3028 KB Output is correct
6 Correct 4 ms 3064 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 3 ms 3156 KB Output is correct
9 Correct 3 ms 3156 KB Output is correct
10 Correct 102 ms 14404 KB Output is correct
11 Correct 200 ms 16228 KB Output is correct
12 Correct 223 ms 16360 KB Output is correct
13 Correct 327 ms 16468 KB Output is correct
14 Correct 746 ms 17240 KB Output is correct
15 Execution timed out 2077 ms 14816 KB Time limit exceeded
16 Halted 0 ms 0 KB -