답안 #818322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
818322 2023-08-10T04:22:21 Z Jarif_Rahman 통행료 (IOI18_highway) C++17
51 / 100
145 ms 9144 KB
#include "highway.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int n, m;
ll A, B;
vector<vector<pair<int, int>>> graph;

ll def;

int find_node(int root){
    vector<int> dis(n, -1);
    queue<int> Q;
    dis[root] = 0;
    Q.push(root);
    vector<int> p(n, -1);
    while(!Q.empty()){
        int nd = Q.front(); Q.pop();
        for(auto [x, i]: graph[nd]) if(dis[x] == -1){
            dis[x] = dis[nd]+1;
            p[x] = i;
            Q.push(x);
        }
    }

    vector<int> o(n);
    for(int i = 0; i < n; i++) o[i] = i;
    sort(o.begin(), o.end(), [&](int a, int b){
        return dis[a] > dis[b];
    });

    int a = 0, b = n-1;
    while(a < b){
        int md = (a+b)/2;
        vector<int> w(m, 1);
        for(int i = 0; i <= md; i++) if(p[o[i]] != -1) w[p[o[i]]] = 0;
        ll x = ask(w);
        if(x < def) b = md;
        else a = md+1;
    }

    return o[a];
}

void find_pair(int _n, vector<int> U, vector<int> V, int _A, int _B){
    swap(n, _n);
    m = U.size();
    A = _A, B = _B;
    graph.resize(n);

    for(int i = 0; i < m; i++){
        graph[U[i]].pb({V[i], i});
        graph[V[i]].pb({U[i], i});
    }

    def = ask(vector<int>(m, 1));

    int a = 0, b = m-1;
    while(a < b){
        int md = (a+b)/2;
        vector<int> w(m, 1);
        for(int i = 0; i <= md; i++) w[i] = 0;
        ll x = ask(w);
        if(x < def) b = md;
        else a = md+1;
    }

    int nd = U[a];
    int s = find_node(nd);
    int t = find_node(s);
    answer(s, t);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 11 ms 1136 KB Output is correct
3 Correct 111 ms 8724 KB Output is correct
4 Correct 103 ms 8648 KB Output is correct
5 Correct 108 ms 8652 KB Output is correct
6 Correct 124 ms 8636 KB Output is correct
7 Correct 114 ms 8648 KB Output is correct
8 Correct 120 ms 8644 KB Output is correct
9 Correct 81 ms 8652 KB Output is correct
10 Correct 100 ms 8652 KB Output is correct
11 Correct 122 ms 8060 KB Output is correct
12 Correct 140 ms 8052 KB Output is correct
13 Correct 105 ms 8048 KB Output is correct
14 Correct 114 ms 8056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1104 KB Output is correct
2 Correct 16 ms 1928 KB Output is correct
3 Correct 67 ms 2824 KB Output is correct
4 Correct 87 ms 8192 KB Output is correct
5 Correct 111 ms 8076 KB Output is correct
6 Correct 108 ms 8068 KB Output is correct
7 Correct 77 ms 8044 KB Output is correct
8 Correct 81 ms 8052 KB Output is correct
9 Correct 73 ms 8024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 9 ms 1136 KB Output is correct
3 Correct 82 ms 6900 KB Output is correct
4 Correct 85 ms 8640 KB Output is correct
5 Correct 105 ms 8628 KB Output is correct
6 Correct 133 ms 8624 KB Output is correct
7 Correct 82 ms 8652 KB Output is correct
8 Correct 86 ms 8628 KB Output is correct
9 Correct 133 ms 8640 KB Output is correct
10 Correct 118 ms 8676 KB Output is correct
11 Correct 123 ms 8044 KB Output is correct
12 Correct 122 ms 8068 KB Output is correct
13 Correct 145 ms 8056 KB Output is correct
14 Correct 116 ms 8052 KB Output is correct
15 Correct 80 ms 8660 KB Output is correct
16 Correct 104 ms 8660 KB Output is correct
17 Correct 105 ms 8076 KB Output is correct
18 Correct 117 ms 8048 KB Output is correct
19 Correct 103 ms 8652 KB Output is correct
20 Correct 100 ms 8064 KB Output is correct
21 Correct 104 ms 9144 KB Output is correct
22 Correct 84 ms 9140 KB Output is correct
23 Correct 80 ms 8940 KB Output is correct
24 Correct 98 ms 9060 KB Output is correct
25 Correct 100 ms 8172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1156 KB Output is correct
2 Incorrect 15 ms 1300 KB Output is incorrect: {s, t} is wrong.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1156 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -