Submission #1017888

# Submission time Handle Problem Language Result Execution time Memory
1017888 2024-07-09T11:05:00 Z mindiyak Highway Tolls (IOI18_highway) C++14
6 / 100
206 ms 262144 KB
#include "highway.h"
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vector<pi>> vvpi;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

int N,M;
vi arr;
vi con;
vvpi paths;
ll none = 0,filled = 0;

ll fill_with(int a,int b){
  vi quest(M,0);
  if(a>=0 && b < M){
    FOR(i,a,b+1){
      quest[con[i]]=1;
    }
  }
  ll val = ask(quest);
  // cout << a << " " << b << " | ";
  // for(int i:quest)cout << i << " ";
  // cout << " - " << val << " | ";
  return val;
}

void dfs(int pos,int prev){
  arr.pb(pos);
  for(auto a:paths[pos]){
    if(a.F == prev)continue;
    con.pb(a.S);
    dfs(a.F,pos);
  }
}

void find_pair(int n, std::vector<int> U, std::vector<int> V, int A, int B) {
  N = n;M = N-1;
  paths = vvpi(N,vpi());
  FOR(i,0,M){
    paths[U[i]].pb({V[i],i});
    paths[V[i]].pb({U[i],i});
  }
  int head = -1;
  FOR(i,0,N){
    if(paths[i].size() == 1){
      head = i;
      break;
    }
  }
  dfs(head,-1);

  // for(int i:arr)cout << i << " ";
  // cout << endl;
  // for(int i:con)cout << i << " ";
  // cout << endl;

  none = fill_with(-1,-1);
  // cout << endl;
  filled = fill_with(0,M-1);
  // cout << endl;

  int l=0,r=M-1;
  while(l<r){
    int mid = (l+r)/2;
    ll count = fill_with(0,mid) - none;
    // cout << count << endl;
    if(count > 0){
      r = mid;
    }else{
      l = mid+1;
    }
  }

  int start = arr[l];
  int end = arr[l+(none/A)];

  // cout << start << " " << end << endl;
  answer(start,end);
}
# 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 1 ms 344 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2044 KB Output is correct
2 Correct 14 ms 3672 KB Output is correct
3 Correct 21 ms 5068 KB Output is correct
4 Correct 63 ms 14980 KB Output is correct
5 Correct 62 ms 14964 KB Output is correct
6 Correct 61 ms 14872 KB Output is correct
7 Correct 63 ms 14980 KB Output is correct
8 Correct 64 ms 14980 KB Output is correct
9 Correct 63 ms 14888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 197 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 206 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -