Submission #778104

# Submission time Handle Problem Language Result Execution time Memory
778104 2023-07-10T06:22:01 Z NeroZein Highway Tolls (IOI18_highway) C++17
5 / 100
213 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;
  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) {
      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
}
# Verdict Execution time Memory 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 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 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 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 11 ms 1200 KB Output is correct
3 Correct 70 ms 8688 KB Output is correct
4 Correct 80 ms 8724 KB Output is correct
5 Correct 68 ms 8696 KB Output is correct
6 Correct 91 ms 8568 KB Output is correct
7 Correct 60 ms 8696 KB Output is correct
8 Correct 94 ms 8684 KB Output is correct
9 Correct 60 ms 8680 KB Output is correct
10 Correct 80 ms 8680 KB Output is correct
11 Correct 104 ms 9052 KB Output is correct
12 Correct 82 ms 9480 KB Output is correct
13 Correct 93 ms 9092 KB Output is correct
14 Incorrect 57 ms 8672 KB Output is incorrect: {s, t} is wrong.
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1488 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 213 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 173 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -