답안 #558631

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

#define see(x) cout<<#x<<"="<<x<<"\n";

using namespace std;

const int N = 1e5+5;

int n, m, used[N], par[N], flag, cycleS, cycleF;
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;
    par[v] = p;
    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]) {
            cycleS = i.first;
            cycleF = v;
        }
        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;
        flag = 0;
        cycleS = cycleF = -1;
        memset(used, 0, sizeof(used));
        par[X] = -1;
        dfs(X, 0, val[mid], X, Y);
        if (cycleS != -1) {
            int f1 = 0, f2 = 0;
            for (int i = cycleS; i != par[cycleF]; i = par[i]) {
                if (i == X) f1 = 1;
                if (i == Y) f2 = 1;
            }
            if (f1 and f2) flag = 1;
        }
        if (used[Y] and flag) {
            best = val[mid];
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
    return best;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 3 ms 3028 KB Output is correct
5 Correct 3 ms 3156 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 4 ms 3156 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 106 ms 13016 KB Output is correct
10 Correct 155 ms 14500 KB Output is correct
11 Correct 177 ms 14788 KB Output is correct
12 Correct 323 ms 14688 KB Output is correct
13 Correct 619 ms 15504 KB Output is correct
14 Execution timed out 2078 ms 13328 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Execution timed out 2087 ms 10928 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 3 ms 3028 KB Output is correct
5 Correct 3 ms 3156 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 4 ms 3156 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 2 ms 3028 KB Output is correct
10 Correct 3 ms 3028 KB Output is correct
11 Correct 3 ms 3028 KB Output is correct
12 Correct 3 ms 3028 KB Output is correct
13 Correct 4 ms 3028 KB Output is correct
14 Correct 3 ms 3028 KB Output is correct
15 Incorrect 3 ms 3132 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
5 Correct 3 ms 3028 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 4 ms 3156 KB Output is correct
10 Correct 106 ms 13016 KB Output is correct
11 Correct 155 ms 14500 KB Output is correct
12 Correct 177 ms 14788 KB Output is correct
13 Correct 323 ms 14688 KB Output is correct
14 Correct 619 ms 15504 KB Output is correct
15 Correct 3 ms 3028 KB Output is correct
16 Correct 3 ms 3028 KB Output is correct
17 Correct 3 ms 3028 KB Output is correct
18 Correct 4 ms 3028 KB Output is correct
19 Correct 3 ms 3028 KB Output is correct
20 Incorrect 3 ms 3132 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 3 ms 3028 KB Output is correct
5 Correct 3 ms 3156 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 4 ms 3156 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 106 ms 13016 KB Output is correct
10 Correct 155 ms 14500 KB Output is correct
11 Correct 177 ms 14788 KB Output is correct
12 Correct 323 ms 14688 KB Output is correct
13 Correct 619 ms 15504 KB Output is correct
14 Execution timed out 2078 ms 13328 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
5 Correct 3 ms 3028 KB Output is correct
6 Correct 3 ms 3156 KB Output is correct
7 Correct 3 ms 3156 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 4 ms 3156 KB Output is correct
10 Correct 106 ms 13016 KB Output is correct
11 Correct 155 ms 14500 KB Output is correct
12 Correct 177 ms 14788 KB Output is correct
13 Correct 323 ms 14688 KB Output is correct
14 Correct 619 ms 15504 KB Output is correct
15 Execution timed out 2078 ms 13328 KB Time limit exceeded
16 Halted 0 ms 0 KB -