QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#304629#8007. Egg Drop Challengeucup-team180#Compile Error//C++173.6kb2024-01-13 22:11:262024-01-13 22:11:27

Judging History

你现在查看的是最新测评结果

  • [2024-01-13 22:11:27]
  • 评测
  • [2024-01-13 22:11:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const double INF = 1000000000000000000;
template <typename T, typename F>
struct abstract_li_chao_tree{
  int N;
  vector<T> x;
  vector<F> ST;
  abstract_li_chao_tree(){
  }
  abstract_li_chao_tree(const vector<T> &x2){
    x = x2;
    sort(x.begin(), x.end());
    int N2 = x.size();
    N = 1;
    while (N < N2){
      N *= 2;
    }
    x.resize(N);
    for (int i = N2; i < N; i++){
      x[i] = x[N2 - 1];
    }
    ST = vector<F>(N * 2 - 1);
  }
  void line_add(F f, int i, int l, int r){
    T la = f.get(x[l]);
    T lb = ST[i].get(x[l]);
    T ra = f.get(x[r - 1]);
    T rb = ST[i].get(x[r - 1]);
    if (la >= lb && ra >= rb){
      return;
    } else if (la <= lb && ra <= rb){
      ST[i] = f;
    } else {
      int m = (l + r) / 2;
      T ma = f.get(x[m]);
      T mb = ST[i].get(x[m]);
      if (ma < mb){
        swap(f, ST[i]);
        swap(la, lb);
        swap(ra, rb);
      }
      if (la < lb){
        line_add(f, i * 2 + 1, l, m);
      }
      if (ra < rb){
        line_add(f, i * 2 + 2, m, r);
      }
    }
  }
  void line_add(F f){
    line_add(f, 0, 0, N);
  }
  T get(T x2){
    int p = lower_bound(x.begin(), x.end(), x2) - x.begin();
    p += N - 1;
    T ans = INF;
    ans = min(ans, ST[p].get(x2));
    while (p > 0){
      p = (p - 1) / 2;
      ans = min(ans, ST[p].get(x2));
    }
    return ans;
  }
};
struct f1{
  double a, b;
  f1(): a(INF), b(0){
  }
  f1(double a, double b): a(a), b(b){
  }
  double get(double x){
    if (b - 2 * x >= 0){
      return a + sqrt(max(b - 2 * x, 0));
    } else {
      return INF;
    }
  }
};
struct f2{
  double a, b;
  f2(): a(INF), b(0){
  }
  f2(double a, double b): a(a), b(b){
  }
  double get(double x){
    if (x - 2 * b >= 0){
      return a - sqrt(max(x - 2 * b, 0));
    } else {
      return INF;
    }
  }
};
int main(){
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<long long> h(n), v(n), u(n);
  for (int i = 0; i < n; i++){
    cin >> h[i] >> v[i] >> u[i];
  }
  vector<long long> V(n), U(n);
  for (int i = 0; i < n; i++){
    V[i] = v[i] * v[i] + 2 * h[i];
    U[i] = u[i] * u[i] + 2 * h[i];
  }
  vector<double> dp(n, INF);
  dp[n - 1] = 0;
  auto dc = [&](auto dc, int L, int R) -> void {
    if (R - L == 1){
      return;
    }
    int m = (L + R) / 2;
    dc(dc, m, R);
    vector<pair<long long, int>> P(R - L);
    for (int i = L; i < m; i++){
      P[i - L] = make_pair(U[i], i);
    }
    for (int i = m; i < R; i++){
      P[i - L] = make_pair(V[i], i);
    }
    sort(P.begin(), P.end());
    vector<double> A(R - m);
    for (int i = m; i < R; i++){
      A[i - m] = dp[i] - v[i];
    }
    vector<double> x1(m - L);
    for (int i = 0; i < m - L; i++){
      x1[i] = h[i];
    }
    abstract_li_chao_tree<double, f1> LCT1(x1);
    for (int i = 0; i < R - L; i++){
      int p = P[i].second;
      if (p >= m){
        LCT1.line_add(f1(A[p - m], V[p]));
      } else {
        dp[p] = min(dp[p], LCT1.query(h[p]));
      }
    }
    reverse(P.begin(), P.end());
    vector<double> B(m - L, INF);
    abstract_li_chao_tree<double, f2> LCT2(x1);
    for (int i = 0; i < R - L; i++){
      int p = P[i].second;
      if (p >= m){
        LCT2.line_add(f2(A[p - m], h[p]));
      } else {
        B[p - L] = min(B[p - L], LCT2.query(U[p]));
      }
    }
    for (int i = L; i < m; i++){
      dp[i] = min(dp[i], B[i - L] + u[i]);
    }
    dc(dc, L, m);
  };
  dc(dc, 0, n);
  if (dp[0] == INF){
    cout << -1 << endl;
  } else {
    cout << dp[0] << endl;
  }
}

詳細信息

answer.code: In member function ‘double f1::get(double)’:
answer.code:74:26: error: no matching function for call to ‘max(double, int)’
   74 |       return a + sqrt(max(b - 2 * x, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:74:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘int’)
   74 |       return a + sqrt(max(b - 2 * x, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:74:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘int’)
   74 |       return a + sqrt(max(b - 2 * x, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:74:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘double’
   74 |       return a + sqrt(max(b - 2 * x, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:74:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘double’
   74 |       return a + sqrt(max(b - 2 * x, 0));
      |                       ~~~^~~~~~~~~~~~~~
answer.code: In member function ‘double f2::get(double)’:
answer.code:88:26: error: no matching function for call to ‘max(double, int)’
   88 |       return a - sqrt(max(x - 2 * b, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:88:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘int’)
   88 |       return a - sqrt(max(x - 2 * b, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:88:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘int’)
   88 |       return a - sqrt(max(x - 2 * b, 0));
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:...