답안 #778121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
778121 2023-07-10T06:28:02 Z NeroZein 통행료 (IOI18_highway) C++17
5 / 100
194 ms 262144 KB
#include "highway.h"
#include "bits/stdc++.h"
using namespace std; 
 
int n, m;
vector<int> pe;
vector<int> dep;
vector<vector<pair<int,int>>> g; 
 
void Dfs (int v, int p) {
  for (auto [u, i] : g[v]) {
    if (u == p) {
      continue;
    }
    pe[u] = i; 
    dep[u] = dep[v] + 1; 
    Dfs(u, v); 
  }
}
 
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
  n = N;
  g.resize(n); 
  pe.resize(n); 
  dep.resize(n); 
  m = (int) U.size(); 
  for (int i = 0; i < m; ++i) {
    g[U[i]].push_back({V[i], i});
    g[V[i]].push_back({U[i], i});
  }
  Dfs(0, 0); 
  vector<int> vec; 
  vector<int> w(m, 0); 
  int dis = ask(w); 
  int depT = dis / A;
  assert(depT != 0); 
  for (int i = 0; i < n; ++i) {
    if (dep[i] == depT) {
      vec.push_back(i); 
    }
  }
  auto fix = [&](vector<int> nodes) {
    vector<int> ret(m);
    for (int u : nodes) {
      assert(u != 0);
      ret[pe[u]] = true; 
    }
    return ret;
  }; 
  while (vec.size() > 1) {
    vector<int> lx, rx;
    int mid = (int) vec.size() / 2;
    for (int i = 0; i < mid; ++i) {
      lx.push_back(vec[i]);
    }
    for (int i = mid; i < (int) vec.size(); ++i) {
      rx.push_back(vec[i]); 
    }
    if (ask(fix(lx)) > dis) {
      vec = lx;
    } else {
      vec = rx; 
    }
  }
  assert(!vec.empty());
  answer(0, vec[0]);//S, T
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 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 0 ms 208 KB Output is correct
10 Correct 0 ms 288 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 6 ms 1136 KB Output is correct
3 Correct 83 ms 8680 KB Output is correct
4 Correct 71 ms 8808 KB Output is correct
5 Correct 66 ms 8656 KB Output is correct
6 Correct 108 ms 8716 KB Output is correct
7 Correct 68 ms 8700 KB Output is correct
8 Correct 83 ms 8688 KB Output is correct
9 Correct 59 ms 8556 KB Output is correct
10 Correct 60 ms 8732 KB Output is correct
11 Correct 59 ms 9060 KB Output is correct
12 Correct 107 ms 9448 KB Output is correct
13 Correct 61 ms 9080 KB Output is correct
14 Incorrect 85 ms 8740 KB Output is incorrect: {s, t} is wrong.
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1572 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 194 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 169 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -