답안 #139422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139422 2019-07-31T16:24:33 Z fredbr 통행료 (IOI18_highway) C++17
51 / 100
391 ms 262148 KB
#include "highway.h"

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int const maxn = 90909;

struct Edge {
    int u, id;
};

vector<Edge> v[maxn];

vector<int> order;
vector<int> vt;

void dfs(int x, int p) {
    for (Edge e : v[x]) {
        if (e.u == p) continue;
        order.push_back(e.id);
        vt.push_back(e.u);
        dfs(e.u, x);
        order.push_back(e.id);
        vt.push_back(x);
    }
}

void find_pair(int n, vector<int> U, vector<int> V, int a, int b) {
    int m = U.size();

    for (int i = 0; i < m; i++) {
        v[U[i]].push_back(Edge{V[i], i});
        v[V[i]].push_back(Edge{U[i], i});
    }

    dfs(0, 0);

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

    int l = 0, r = (int)order.size();

    while (r-l > 1) {
        int mid = (l+r)/2;

        vector<int> q(m, 0);
        for (int i = 0; i < mid; i++)
            q[order[i]] = 1;

        ll cost = ask(q);

        if (cost == total_cost) r = mid;
        else l = mid;
    }
    a = vt[l];

    r = (int)order.size();

    order.clear();
    vt.clear();

    dfs(a, a);

    l = 0, r = (int)order.size();

    while (r-l > 1) {
        int mid = (l+r)/2;

        vector<int> q(m, 0);
        for (int i = 0; i < mid; i++)
            q[order[i]] = 1;

        ll cost = ask(q);

        if (cost == total_cost) r = mid;
        else l = mid;
    }

    b = vt[l];

    answer(a, b);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2424 KB Output is correct
2 Correct 4 ms 2452 KB Output is correct
3 Correct 4 ms 2428 KB Output is correct
4 Correct 4 ms 2424 KB Output is correct
5 Correct 4 ms 2424 KB Output is correct
6 Correct 4 ms 2428 KB Output is correct
7 Correct 5 ms 2424 KB Output is correct
8 Correct 4 ms 2424 KB Output is correct
9 Correct 4 ms 2424 KB Output is correct
10 Correct 4 ms 2424 KB Output is correct
11 Correct 4 ms 2424 KB Output is correct
12 Correct 4 ms 2424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2424 KB Output is correct
2 Correct 35 ms 3284 KB Output is correct
3 Correct 229 ms 9032 KB Output is correct
4 Correct 228 ms 9020 KB Output is correct
5 Correct 201 ms 9116 KB Output is correct
6 Correct 229 ms 9024 KB Output is correct
7 Correct 221 ms 9084 KB Output is correct
8 Correct 197 ms 9016 KB Output is correct
9 Correct 243 ms 9028 KB Output is correct
10 Correct 199 ms 9004 KB Output is correct
11 Correct 228 ms 10192 KB Output is correct
12 Correct 225 ms 11160 KB Output is correct
13 Correct 237 ms 10432 KB Output is correct
14 Correct 228 ms 10452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3988 KB Output is correct
2 Correct 40 ms 5496 KB Output is correct
3 Correct 69 ms 6908 KB Output is correct
4 Correct 193 ms 15504 KB Output is correct
5 Correct 164 ms 15524 KB Output is correct
6 Correct 202 ms 15532 KB Output is correct
7 Correct 172 ms 15516 KB Output is correct
8 Correct 172 ms 15508 KB Output is correct
9 Correct 180 ms 15508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2424 KB Output is correct
2 Correct 27 ms 3216 KB Output is correct
3 Correct 159 ms 7864 KB Output is correct
4 Correct 226 ms 9020 KB Output is correct
5 Correct 210 ms 9056 KB Output is correct
6 Correct 217 ms 9024 KB Output is correct
7 Correct 192 ms 9020 KB Output is correct
8 Correct 232 ms 9112 KB Output is correct
9 Correct 226 ms 9008 KB Output is correct
10 Correct 202 ms 9024 KB Output is correct
11 Correct 274 ms 9712 KB Output is correct
12 Correct 211 ms 11008 KB Output is correct
13 Correct 217 ms 10520 KB Output is correct
14 Correct 288 ms 10940 KB Output is correct
15 Correct 174 ms 9200 KB Output is correct
16 Correct 183 ms 9004 KB Output is correct
17 Correct 251 ms 10724 KB Output is correct
18 Correct 258 ms 10744 KB Output is correct
19 Correct 233 ms 9020 KB Output is correct
20 Correct 151 ms 11628 KB Output is correct
21 Correct 164 ms 9772 KB Output is correct
22 Correct 205 ms 9704 KB Output is correct
23 Correct 138 ms 9732 KB Output is correct
24 Correct 228 ms 10404 KB Output is correct
25 Correct 233 ms 14912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 391 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 371 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -