답안 #428990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428990 2021-06-15T16:13:53 Z proma 자매 도시 (APIO20_swap) C++17
17 / 100
2000 ms 16304 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX = 1e5+5;
const int INF = 1e9;

int n, m, used[MAX];
vector <pair <int, int>> g[MAX];

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]});
    }
}

void dfs (int v, int p, int k, int& flag){
    used[v] = 1;
    int deg = 0;
    for (auto i: g[v]) {
        if (i.second <= k and i.first != p and used[i.first] == 1)
            flag = 1;
        if (i.second <= k and !used[i.first])
            dfs(i.first, v, k, flag);
        if (i.second <= k)
            deg ++;
    }
    if (deg >= 3) flag = 1;
    used[v] = 2;
}

bool isPossible (int a, int b, int k) {
    memset(used, 0, sizeof(used));
    int flag = 0;
    dfs(a, -1, k, flag);
    if (flag and used[b]) return true;
    else return false;
}

int getMinimumFuelCapacity (int X, int Y) {
    int l = 1, r = INF, best = -1;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (isPossible(X, Y, mid)) {
            best = mid;
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
    return best;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 3 ms 3020 KB Output is correct
3 Correct 4 ms 3020 KB Output is correct
4 Correct 5 ms 3020 KB Output is correct
5 Correct 6 ms 3148 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3180 KB Output is correct
8 Correct 8 ms 3148 KB Output is correct
9 Correct 373 ms 13816 KB Output is correct
10 Correct 953 ms 15448 KB Output is correct
11 Correct 1480 ms 15716 KB Output is correct
12 Correct 1319 ms 15584 KB Output is correct
13 Execution timed out 2091 ms 16304 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 3 ms 3020 KB Output is correct
3 Execution timed out 2041 ms 12096 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 3 ms 3020 KB Output is correct
3 Correct 4 ms 3020 KB Output is correct
4 Correct 5 ms 3020 KB Output is correct
5 Correct 6 ms 3148 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3180 KB Output is correct
8 Correct 8 ms 3148 KB Output is correct
9 Correct 3 ms 3020 KB Output is correct
10 Correct 6 ms 3048 KB Output is correct
11 Correct 8 ms 3020 KB Output is correct
12 Correct 8 ms 3120 KB Output is correct
13 Correct 8 ms 3040 KB Output is correct
14 Correct 8 ms 3020 KB Output is correct
15 Correct 7 ms 3044 KB Output is correct
16 Correct 8 ms 3148 KB Output is correct
17 Correct 8 ms 3044 KB Output is correct
18 Correct 7 ms 3020 KB Output is correct
19 Correct 6 ms 3060 KB Output is correct
20 Correct 8 ms 3160 KB Output is correct
21 Correct 7 ms 3020 KB Output is correct
22 Correct 7 ms 3176 KB Output is correct
23 Correct 6 ms 3020 KB Output is correct
24 Correct 8 ms 3168 KB Output is correct
25 Correct 8 ms 3148 KB Output is correct
26 Correct 11 ms 3148 KB Output is correct
27 Correct 8 ms 3096 KB Output is correct
28 Correct 10 ms 3172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 3 ms 3020 KB Output is correct
3 Correct 3 ms 3020 KB Output is correct
4 Correct 4 ms 3020 KB Output is correct
5 Correct 5 ms 3020 KB Output is correct
6 Correct 6 ms 3148 KB Output is correct
7 Correct 7 ms 3148 KB Output is correct
8 Correct 8 ms 3180 KB Output is correct
9 Correct 8 ms 3148 KB Output is correct
10 Correct 373 ms 13816 KB Output is correct
11 Correct 953 ms 15448 KB Output is correct
12 Correct 1480 ms 15716 KB Output is correct
13 Correct 1319 ms 15584 KB Output is correct
14 Execution timed out 2091 ms 16304 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 3 ms 3020 KB Output is correct
3 Correct 4 ms 3020 KB Output is correct
4 Correct 5 ms 3020 KB Output is correct
5 Correct 6 ms 3148 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3180 KB Output is correct
8 Correct 8 ms 3148 KB Output is correct
9 Correct 373 ms 13816 KB Output is correct
10 Correct 953 ms 15448 KB Output is correct
11 Correct 1480 ms 15716 KB Output is correct
12 Correct 1319 ms 15584 KB Output is correct
13 Execution timed out 2091 ms 16304 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 3 ms 3020 KB Output is correct
3 Correct 3 ms 3020 KB Output is correct
4 Correct 4 ms 3020 KB Output is correct
5 Correct 5 ms 3020 KB Output is correct
6 Correct 6 ms 3148 KB Output is correct
7 Correct 7 ms 3148 KB Output is correct
8 Correct 8 ms 3180 KB Output is correct
9 Correct 8 ms 3148 KB Output is correct
10 Correct 373 ms 13816 KB Output is correct
11 Correct 953 ms 15448 KB Output is correct
12 Correct 1480 ms 15716 KB Output is correct
13 Correct 1319 ms 15584 KB Output is correct
14 Execution timed out 2091 ms 16304 KB Time limit exceeded