結果

問題 No.620 ぐるぐるぐるりん
ユーザー pekempeypekempey
提出日時 2017-12-20 01:50:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,529 bytes
コンパイル時間 1,047 ms
コンパイル使用メモリ 85,564 KB
実行使用メモリ 5,276 KB
最終ジャッジ日時 2023-08-22 07:30:02
合計ジャッジ時間 5,520 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 21 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 21 ms
4,380 KB
testcase_30 AC 22 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <random>

using namespace std;

const double pi = acos(-1);
mt19937 mt(123456);

void solve() {
  int t;
  double p, w, v, gx, gy;
  cin >> t >> p >> w >> v >> gx >> gy;

  double gr = hypot(gx, gy);
  double mn = 1e100;

  for (int ii = 0; ii < 500; ii++) {
    double x = 1;
    double y = 0;

    vector<double> vx(t);
    vector<double> vy(t);

    double det = hypot(1 + v, w);

    double theta = uniform_real_distribution<double>(0, 2*pi)(mt);
    double c = det * exp(-(double)ii / 500 * 10);
    vx[0] = cos(theta) - 1;
    vy[0] = sin(theta);

    for (int i = 0; i < t; i++) {
      double x0 = x;
      double y0 = y;

      x = x0 - y0*w + x0*v + vx[i];
      y = y0 + x0*w + y0*v + vy[i];

      double r = hypot(x, y);
      double tr;

      tr = 1;
      if (i == t - 2) tr = gr * c;
      double d = tr - r;

      vx[i] += d*x / r;
      vy[i] += d*y / r;

      x += d*x / r;
      y += d*y / r;
    }

    vx[t - 1] += gx - x;
    vy[t - 1] += gy - y;

    double s = 0;
    for (int i = 0; i < t; i++) {
      s += vx[i]*vx[i] + vy[i]*vy[i];
    }
    mn = min(mn, s);

    if (s < p - 0.001) {
      for (int i = 0; i < t; i++) {
        printf("%.16f %.16f\n", vx[i], vy[i]);
      }

      fprintf(stderr, "Sum: %.16f\n", s);
      fprintf(stderr, "p:   %.16f\n", p);

      return;
    }
  }
  cout << "FAIL" << endl;
  cout << endl;
  cout << mn << endl;
}

int main() {
  int T;
  cin >> T;
  while (T--) solve();
}
0