답안 #903570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
903570 2024-01-11T08:37:19 Z 12345678 통행료 (IOI18_highway) C++17
51 / 100
109 ms 9700 KB
#include "highway.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=1e5+5;
int id[nx], t, vs[nx], res[nx], l, r, h;
vector<pair<int, int>> d[nx];

void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
    vector<int> qs(N-1);
    for (int i=0; i<U.size(); i++) d[U[i]].push_back({V[i], i}), d[V[i]].push_back({U[i], i});
    ll length=ask(qs)/A;
    queue<int> q;
    q.push(0);
    vs[0]=1;
    while (!q.empty())
    {
        int u=q.front();
        q.pop();
        for (auto [v, idx]:d[u]) if (!vs[v]) res[t]=v, id[t++]=idx, vs[v]=1, q.push(v);
    }
    l=0, r=N-1;
    while (l<r)
    {
        int md=(l+r)/2;
        for (int i=0; i<N-1; i++) qs[i]=0;
        for (int i=0; i<=md; i++) qs[id[i]]=1;
        if (ask(qs)/B==length) r=md;
        else l=md+1;
    }
    int h=res[l];
    t=0;
    for (int i=0; i<N; i++) vs[i]=0;
    q.push(h);
    vs[h]=1;
    while (!q.empty())
    {
        int u=q.front();
        q.pop();
        for (auto [v, idx]:d[u]) if (!vs[v]) res[t]=v, id[t++]=idx, vs[v]=1, q.push(v);
    }
    l=0, r=N-1;
    while (l<r)
    {
        int md=(l+r)/2;
        for (int i=0; i<N-1; i++) qs[i]=0;
        for (int i=0; i<=md; i++) qs[id[i]]=1;
        if (ask(qs)/B==length) r=md;
        else l=md+1;
    }
    answer(h, res[l]);
}

Compilation message

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i=0; i<U.size(); i++) d[U[i]].push_back({V[i], i}), d[V[i]].push_back({U[i], i});
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2796 KB Output is correct
2 Correct 1 ms 2956 KB Output is correct
3 Correct 1 ms 2792 KB Output is correct
4 Correct 1 ms 2804 KB Output is correct
5 Correct 1 ms 2804 KB Output is correct
6 Correct 1 ms 2808 KB Output is correct
7 Correct 1 ms 2812 KB Output is correct
8 Correct 1 ms 2808 KB Output is correct
9 Correct 1 ms 2808 KB Output is correct
10 Correct 1 ms 2812 KB Output is correct
11 Correct 1 ms 2804 KB Output is correct
12 Correct 1 ms 2792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2852 KB Output is correct
2 Correct 11 ms 3360 KB Output is correct
3 Correct 95 ms 9476 KB Output is correct
4 Correct 88 ms 9260 KB Output is correct
5 Correct 100 ms 9024 KB Output is correct
6 Correct 86 ms 9020 KB Output is correct
7 Correct 89 ms 9256 KB Output is correct
8 Correct 78 ms 9268 KB Output is correct
9 Correct 85 ms 9252 KB Output is correct
10 Correct 85 ms 9256 KB Output is correct
11 Correct 109 ms 8888 KB Output is correct
12 Correct 103 ms 8660 KB Output is correct
13 Correct 98 ms 9116 KB Output is correct
14 Correct 108 ms 8660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3340 KB Output is correct
2 Correct 15 ms 3816 KB Output is correct
3 Correct 24 ms 4928 KB Output is correct
4 Correct 66 ms 8596 KB Output is correct
5 Correct 67 ms 8880 KB Output is correct
6 Correct 102 ms 8428 KB Output is correct
7 Correct 76 ms 8656 KB Output is correct
8 Correct 55 ms 8668 KB Output is correct
9 Correct 70 ms 8636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2848 KB Output is correct
2 Correct 15 ms 3356 KB Output is correct
3 Correct 59 ms 7652 KB Output is correct
4 Correct 81 ms 9476 KB Output is correct
5 Correct 104 ms 9256 KB Output is correct
6 Correct 79 ms 9256 KB Output is correct
7 Correct 81 ms 9032 KB Output is correct
8 Correct 91 ms 9484 KB Output is correct
9 Correct 92 ms 9480 KB Output is correct
10 Correct 101 ms 9488 KB Output is correct
11 Correct 90 ms 8860 KB Output is correct
12 Correct 83 ms 8652 KB Output is correct
13 Correct 89 ms 8808 KB Output is correct
14 Correct 93 ms 8676 KB Output is correct
15 Correct 80 ms 9264 KB Output is correct
16 Correct 70 ms 9504 KB Output is correct
17 Correct 88 ms 8664 KB Output is correct
18 Correct 84 ms 8652 KB Output is correct
19 Correct 82 ms 9256 KB Output is correct
20 Correct 72 ms 8660 KB Output is correct
21 Correct 71 ms 9504 KB Output is correct
22 Correct 74 ms 9500 KB Output is correct
23 Correct 76 ms 9556 KB Output is correct
24 Correct 81 ms 9700 KB Output is correct
25 Correct 90 ms 8776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 3416 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 3416 KB Incorrect
2 Halted 0 ms 0 KB -