Submission #1018313

# Submission time Handle Problem Language Result Execution time Memory
1018313 2024-07-09T18:49:45 Z vjudge1 Highway Tolls (IOI18_highway) C++17
0 / 100
204 ms 262144 KB
#include "highway.h"
#include<bits/stdc++.h>
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using namespace std;
using lli=long long;
void dfs(int x, int p, vector<int> &level, vector<vector<int>> &adj){
  for(int y: adj[x]){
    if(y==p) continue;
    level[y]=level[x]+1;
    dfs(y,x,level,adj);
  }
}

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
  vector<int> level (N);
  level[0]=0;
  vector<vector<int>> adj (N);
  for(int i=0; i<N-1; ++i){
    adj[U[i]].pb(V[i]);
    adj[V[i]].pb(U[i]);
  }
  dfs(0,-1,level,adj);

  vector<vector<int>> arle(N);
  for(int i=0; i<N-1; ++i){
    
    int x=max(level[U[i]], level[V[i]]);

    arle[x].pb(i);

  }
  vector<int> aux (N-1,0);

  lli v=ask(aux);
  lli d=v/A;
//  deb(d);
  vector<lli> val;
  vector<lli> arista;
  for(lli x: arle[d]){
    arista.pb(x);
    if(level[U[x]]==d){
      val.pb(U[x]);
    }    
    else{
      val.pb(V[x]);
    }
  //  deb(val[val.size()-1]);
  }
  lli l=0;
  lli r=val.size();
  while(r-l>1){
    lli m=(r+l)/2;
    vector<int> aux (N-1,0);
    for(lli i=0; i<=m; ++i){
      aux[arista[i]]=1;
    }
    v=ask(aux);
    if(v==d*A){
      l=m+1;
    }
    else{
      r=m;
    }
  }
  answer(0, val[l]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output is incorrect: {s, t} is wrong.
3 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 Incorrect 7 ms 2392 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 Runtime error 202 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 204 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -