QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#423469#7110. Kuririn MIRACLEucup-team3215AC ✓469ms3936kbC++201.7kb2024-05-28 03:13:202024-05-28 03:13:21

Judging History

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

  • [2024-05-28 03:13:21]
  • 评测
  • 测评结果:AC
  • 用时:469ms
  • 内存:3936kb
  • [2024-05-28 03:13:20]
  • 提交

answer

#include <array>
#include <cmath>
#include <iostream>

using namespace std;

double midpoint(double r, double d, double mt, double h, auto& deriv) {
  double x = 0, y = 0, t = 0, c = 1;
  auto mp = [&] {
    auto [dx, dy] = deriv(x, y, t);
    return deriv(x + dx * h * c / 2, y + dy * h * c / 2, t + h * c / 2);
  };
  while (1) {
    // cout << t << ' ' << x << ' ' << y << ' ' << (x - t - 2 * r) * (x - t - 2 * r) + y * y - 4 * r * r << '\n';
    if (t >= mt) return 1. / 0;
    if (c < 1e-9) return t + sqrt((x - d) * (x - d) + y * y) / 2;
    auto [dx, dy] = mp();
    auto nx = x + dx * h * c, ny = y + dy * h * c, nt = t + h * c;
    auto [ndx, ndy] = deriv(nx, ny, nt);
    if (ndy < 0 && nx - ny / ndy * ndx < d) { c /= 2; continue; }
    x = nx, y = ny, t = nt;
    double coef = sqrt(((x - t - 2 * r) * (x - t - 2 * r) + y * y) / (4 * r * r));
    // if (abs(coef - 1) > 1e-12) {
    //   x = (t + 2 * r) + (x - t - 2 * r) / coef;
    //   y = y / coef;
    // }
  }
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  for (int tc = (cin >> tc, tc); tc--; ) {
    double v, r, d; cin >> v >> r >> d;
    auto deriv = [&](double x, double y, double t) -> array<double, 2> {
      double dx = x - t - 2 * r;
      if (abs(dx) < y) {
        double r = -dx / y, rr = r * r;
        double ux = (rr + sqrt(3 * rr + 4)) / (1 + rr);
        return {ux, (ux - 1) * r};
      } else {
        double r = -y / dx, rr = r * r, d = sqrt(4 * rr + 3);
        double uy = (-r + (dx < 0? d: -d)) / (1 + rr);
        return {uy * r + 1, uy};
      }
    };
    cout.precision(20);
    double ans = d;
    if (d >= 7 * r) ans = min(ans, midpoint(r, d, d - 4 * r, (d - 4 * r) / 3e4, deriv));
    cout << ans / v << '\n';
  }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3928kb

input:

1
2.00 3 30.0

output:

8.3105799274580505198

result:

ok found '8.3105799', expected '8.3105799', error '0.0000000'

Test #2:

score: 0
Accepted
time: 53ms
memory: 3936kb

input:

100
8.66 6.05 71.59
8.44 8.67 82.55
4.23 9.68 24.74
6.63 9.95 7.45
1.2 7.27 97.55
2.08 2.94 31.61
8.48 5.56 20.16
7.35 5.55 52.48
1.35 8.15 51.23
3.88 9.02 72.37
7.03 1.97 57.03
1.78 4.44 93.44
5.5 6.11 52.94
1.09 9.64 69.01
1.01 3.54 16.78
1.63 4.55 44.06
5.82 5.51 5.92
5.62 2.93 76.01
4.75 4.43 73...

output:

4.457837118664766507
5.488360804602489651
5.8486997635933795081
1.1236802413273001555
43.266480006613754483
8.3054901314278204438
2.3773584905660376521
4.015485966240881055
37.948148148148142411
18.652061855670105217
4.1551236310878651992
27.178962952515156815
9.6254545454545450411
63.31192660550458...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 469ms
memory: 3772kb

input:

1000
7.52 6.68 80.67
5.34 6.82 45.75
3.57 6.35 22.35
9.55 3.65 31.38
9.37 5.73 40.42
1.83 8.38 82.97
4.86 6.13 9.45
3.88 5.34 84.19
6.49 4.15 85.24
6.51 7.23 42.97
3.0 5.98 57.53
9.35 2.76 69.07
6.76 9.16 91.24
2.98 9.89 49.2
9.16 3.85 66.14
1.84 3.03 37.43
8.01 5.04 50.98
4.05 9.86 4.76
5.4 5.49 60...

output:

5.7708826438367903933
8.5674157303370783723
6.2605042016806731198
3.2858638743455492737
4.3137673425827109952
25.17648415252670091
1.9444444444444441977
11.406299600870712041
6.8071911924198458266
6.6006144393241168444
10.727712552375871624
3.8001978352897518576
7.4844842968237390579
16.510067114093...

result:

ok 1000 numbers

Extra Test:

score: 0
Extra Test Passed