답안 #594327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594327 2022-07-12T10:59:52 Z Soumya1 통행료 (IOI18_highway) C++17
100 / 100
248 ms 11764 KB
#include "highway.h"
#include <bits/stdc++.h>
#ifdef __LOCAL__
  #include <debug_local.h>
#endif
using namespace std;
const int mxN = 9e4 + 5;
vector<pair<int, int>> ad[mxN];
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++) {
    ad[U[i]].push_back({i, V[i]});
    ad[V[i]].push_back({i, U[i]});
  }
  int lo = 0, hi = m - 1;
  int len = ask(vector<int> (m)) / A;
  while (lo < hi) {
    int mid = (lo + hi) >> 1;
    vector<int> v(U.size(), 1);
    for (int i = 0; i <= mid; i++) {
      v[i] = 0;
    }
    if (ask(v) == 1LL * A * len) hi = mid;
    else lo = mid + 1;
  }
  int s = U[lo], e = V[lo];
  vector<int> d(n, -1), root(n);
  root[s] = s, root[e] = e;
  queue<int> q;
  vector<int> S, E, par(n);
  par[s] = par[e] = lo;
  S.push_back(s);
  E.push_back(e);
  q.push(s);
  q.push(e);
  d[s] = d[e] = lo;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto [i, v] : ad[u]) {
      if (d[v] == -1) {
        d[v] = d[u] + 1;
        q.push(v);
        root[v] = root[u];
        if (root[v] == s) {
          S.push_back(v);
          par[v] = i;
        } else {
          E.push_back(v);
          par[v] = i;
        }
      }
    }
  }
  auto get = [&](vector<int> ss, vector<int> ee) {
    lo = 0, hi = ss.size() - 1;
    while (lo < hi) {
      int mid = (lo + hi) >> 1;
      vector<int> v(m, 1);
      for (int i = 0; i < ee.size(); i++) v[par[ee[i]]] = 0;
      for (int i = 0; i <= mid; i++) {
        v[par[ss[i]]] = 0;
      }
      if (ask(v) == 1LL * len * A) hi = mid;
      else lo = mid + 1;
    }
    return ss[lo];
  };
  answer(get(S, E), get(E, S));
}

Compilation message

highway.cpp: In lambda function:
highway.cpp:60:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |       for (int i = 0; i < ee.size(); i++) v[par[ee[i]]] = 0;
      |                       ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 2 ms 2420 KB Output is correct
6 Correct 2 ms 2384 KB Output is correct
7 Correct 2 ms 2384 KB Output is correct
8 Correct 1 ms 2420 KB Output is correct
9 Correct 2 ms 2420 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 10 ms 3124 KB Output is correct
3 Correct 151 ms 9788 KB Output is correct
4 Correct 145 ms 9704 KB Output is correct
5 Correct 144 ms 9360 KB Output is correct
6 Correct 152 ms 9704 KB Output is correct
7 Correct 114 ms 9672 KB Output is correct
8 Correct 139 ms 9820 KB Output is correct
9 Correct 124 ms 9816 KB Output is correct
10 Correct 149 ms 9748 KB Output is correct
11 Correct 139 ms 9196 KB Output is correct
12 Correct 153 ms 9168 KB Output is correct
13 Correct 136 ms 9184 KB Output is correct
14 Correct 163 ms 9140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3152 KB Output is correct
2 Correct 23 ms 3920 KB Output is correct
3 Correct 27 ms 4752 KB Output is correct
4 Correct 102 ms 9284 KB Output is correct
5 Correct 132 ms 9200 KB Output is correct
6 Correct 113 ms 9264 KB Output is correct
7 Correct 122 ms 9140 KB Output is correct
8 Correct 148 ms 9160 KB Output is correct
9 Correct 86 ms 9272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 16 ms 3224 KB Output is correct
3 Correct 87 ms 8076 KB Output is correct
4 Correct 140 ms 9772 KB Output is correct
5 Correct 104 ms 9700 KB Output is correct
6 Correct 104 ms 9700 KB Output is correct
7 Correct 156 ms 9724 KB Output is correct
8 Correct 145 ms 9704 KB Output is correct
9 Correct 163 ms 9868 KB Output is correct
10 Correct 117 ms 9712 KB Output is correct
11 Correct 150 ms 9228 KB Output is correct
12 Correct 138 ms 9320 KB Output is correct
13 Correct 161 ms 9212 KB Output is correct
14 Correct 139 ms 9228 KB Output is correct
15 Correct 102 ms 9648 KB Output is correct
16 Correct 112 ms 9616 KB Output is correct
17 Correct 131 ms 9128 KB Output is correct
18 Correct 136 ms 9124 KB Output is correct
19 Correct 99 ms 9720 KB Output is correct
20 Correct 115 ms 9140 KB Output is correct
21 Correct 86 ms 10068 KB Output is correct
22 Correct 104 ms 10356 KB Output is correct
23 Correct 129 ms 10200 KB Output is correct
24 Correct 165 ms 10160 KB Output is correct
25 Correct 180 ms 9228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3152 KB Output is correct
2 Correct 15 ms 3268 KB Output is correct
3 Correct 160 ms 10296 KB Output is correct
4 Correct 138 ms 10616 KB Output is correct
5 Correct 225 ms 11764 KB Output is correct
6 Correct 215 ms 11524 KB Output is correct
7 Correct 187 ms 11556 KB Output is correct
8 Correct 179 ms 11616 KB Output is correct
9 Correct 142 ms 8700 KB Output is correct
10 Correct 142 ms 9092 KB Output is correct
11 Correct 129 ms 9660 KB Output is correct
12 Correct 162 ms 10852 KB Output is correct
13 Correct 183 ms 11188 KB Output is correct
14 Correct 192 ms 11556 KB Output is correct
15 Correct 202 ms 11612 KB Output is correct
16 Correct 170 ms 9784 KB Output is correct
17 Correct 184 ms 10196 KB Output is correct
18 Correct 157 ms 10404 KB Output is correct
19 Correct 117 ms 10328 KB Output is correct
20 Correct 157 ms 10420 KB Output is correct
21 Correct 202 ms 11488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3284 KB Output is correct
2 Correct 10 ms 3308 KB Output is correct
3 Correct 118 ms 10136 KB Output is correct
4 Correct 184 ms 10320 KB Output is correct
5 Correct 190 ms 10588 KB Output is correct
6 Correct 174 ms 11552 KB Output is correct
7 Correct 149 ms 10320 KB Output is correct
8 Correct 185 ms 10340 KB Output is correct
9 Correct 162 ms 10516 KB Output is correct
10 Correct 230 ms 11612 KB Output is correct
11 Correct 245 ms 11516 KB Output is correct
12 Correct 178 ms 11524 KB Output is correct
13 Correct 131 ms 9696 KB Output is correct
14 Correct 135 ms 9108 KB Output is correct
15 Correct 174 ms 9592 KB Output is correct
16 Correct 140 ms 9084 KB Output is correct
17 Correct 209 ms 9584 KB Output is correct
18 Correct 126 ms 9180 KB Output is correct
19 Correct 164 ms 10940 KB Output is correct
20 Correct 172 ms 11232 KB Output is correct
21 Correct 235 ms 11568 KB Output is correct
22 Correct 190 ms 11624 KB Output is correct
23 Correct 231 ms 11640 KB Output is correct
24 Correct 175 ms 11480 KB Output is correct
25 Correct 189 ms 11656 KB Output is correct
26 Correct 248 ms 11584 KB Output is correct
27 Correct 135 ms 10032 KB Output is correct
28 Correct 117 ms 10248 KB Output is correct
29 Correct 117 ms 10488 KB Output is correct
30 Correct 134 ms 10452 KB Output is correct
31 Correct 125 ms 10312 KB Output is correct
32 Correct 127 ms 10272 KB Output is correct
33 Correct 126 ms 10484 KB Output is correct
34 Correct 165 ms 10304 KB Output is correct
35 Correct 93 ms 10332 KB Output is correct
36 Correct 127 ms 10248 KB Output is correct
37 Correct 166 ms 10420 KB Output is correct
38 Correct 121 ms 10372 KB Output is correct
39 Correct 218 ms 11540 KB Output is correct
40 Correct 167 ms 11564 KB Output is correct
41 Correct 224 ms 11492 KB Output is correct
42 Correct 200 ms 11520 KB Output is correct