Submission #1095868

# Submission time Handle Problem Language Result Execution time Memory
1095868 2024-10-03T10:51:52 Z owoovo Highway Tolls (IOI18_highway) C++17
0 / 100
291 ms 262144 KB
#include "highway.h"
#include<bits/stdc++.h>
#define ll long long
#define F first 
#define S second 
using namespace std;
vector<int> e[90010];
int n,dp[90010];
void dfs(int now,int last){
  dp[now]=dp[last]+1;
  for(auto x:e[now]){
    if(x==last)continue;
    dfs(x,now);
  }
  return;
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
  int M = U.size();
  vector<int> w;
  w.resize(M);
  for(auto x:w)x=0;
  for(int i=0;i<M;i++){
    e[U[i]].push_back(V[i]);
    e[V[i]].push_back(U[i]);
  }
  dp[0]=-1;
  dfs(0,0);
  ll now=ask(w);
  ll need=now/A;
  vector<int> may;
  for(int i=0;i<N;i++){
    if(dp[i]==need)may.push_back(i);
  }
  int l=0,r=may.size();
  while(l<r-1){
    int m=(l+r)>>1;
    for(int i=0;i<M;i++)w[i]=0;
    for(int i=l;i<m;i++){
      w[may[i]]=1;
    }
    ll ne=ask(w);
    if(ne!=now){
      r=m;
    }else{
      l=m;
    }
  }
  answer(0, may[l]);
}

Compilation message

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:21:12: warning: variable 'x' set but not used [-Wunused-but-set-variable]
   21 |   for(auto x:w)x=0;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2392 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 3416 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2392 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 283 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 291 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -