Submission #1037900

# Submission time Handle Problem Language Result Execution time Memory
1037900 2024-07-29T09:55:38 Z Mr_Husanboy Highway Tolls (IOI18_highway) C++17
12 / 100
65 ms 8804 KB
#include "highway.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()

template<typename T>
int len(T &a){
  return a.size();
}

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

vector<vector<int>> g;
vector<int> u, v;
int n, m;

vector<int> nodes, ch;

void dfs(int tar, int i, int p = -1, int d = 0){
  for(auto j : g[i]){
    int x = u[j] ^ v[j] ^ i;
    if(x == p) continue;
    if(d + 1 == tar){
      nodes.push_back(j);
      ch.push_back(x);
    }else{
      dfs(tar, x, i, d + 1);
    }
  }
}

void find_pair(int N, std::vector<int> U, std::vector<int> V, int a, int b) {
  n = N;
  u = U;
  v = V;
  m = len(v);
  g.resize(n);
  for(int i = 0; i < m; i ++){
    g[u[i]].push_back(i);
    g[v[i]].push_back(i);
  }
  vector<int> w(m);
  ll d = ask(w) / a;
  dfs(d, 0);
  int l = -1, r = len(nodes) - 1;
  //cout << r << endl;
  //for(auto u : ch) cout << u << endl;
  while(r - l > 1){
    int mid = (l + r) / 2;
    for(int i = 0; i <= mid; i ++){
      w[nodes[i]] = 1;
    }
    for(int i = mid + 1; i < len(nodes); i ++){
      w[nodes[i]] = 0;
    }
    if(ask(w) != d * a){
      r = mid;
    }else l = mid;
  }
  //cout << r << endl;
  answer(0, ch[r]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 8 ms 1368 KB Output is correct
3 Correct 59 ms 8108 KB Output is correct
4 Correct 65 ms 8104 KB Output is correct
5 Correct 57 ms 8100 KB Output is correct
6 Correct 62 ms 8004 KB Output is correct
7 Correct 60 ms 8016 KB Output is correct
8 Correct 64 ms 8180 KB Output is correct
9 Correct 62 ms 7776 KB Output is correct
10 Correct 60 ms 8108 KB Output is correct
11 Correct 57 ms 8256 KB Output is correct
12 Correct 56 ms 8788 KB Output is correct
13 Correct 51 ms 8528 KB Output is correct
14 Correct 64 ms 8804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1112 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 2260 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1368 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -