結果
| 問題 |
No.620 ぐるぐるぐるりん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-20 18:11:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,691 bytes |
| コンパイル時間 | 1,001 ms |
| コンパイル使用メモリ | 87,924 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-12-16 07:07:38 |
| 合計ジャッジ時間 | 8,885 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 8 WA * 19 TLE * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;
const double pi = acos(-1);
mt19937 mt(123456);
int t;
long double p, w, v, gx, gy;
long double hypot2(long double x, long double y) {
return x*x + y*y;
}
bool solve2() {
long double gr = hypot(gx, gy);
long double mn = 1e100;
long double x = v+1;
long double y = w;
long double det = (1+v)*(1+v) + w*w;
long double gx = ::gx;
long double gy = ::gy;
if (t >= 2 && hypot2(x, y) + hypot2(gx, gy) < p - 0.00001) {
printf("%.30Lf %.30Lf\n", -x, -y);
for (int j = 0; j < t - 2; j++) {
printf("%.30Lf %.30Lf\n", 0.0L, 0.0L);
}
printf("%.30Lf %.30Lf\n", gx, gy);
return true;
}
for (int i = 0; i < t - 1; i++) {
long double gx0 = gx;
long double gy0 = gy;
gx = gx0*(v+1) + gy0*w;
gy = gy0*(v+1) - gx0*w;
gx /= det;
gy /= det;
long double dist = hypot(gx, gy);
long double score = dist*dist + x*x + y*y;
if (score < p - 0.00001) {
printf("%.30Lf %.30Lf\n", -x, -y);
for (int j = 0; j < t - 3 - i; j++) {
printf("%.30Lf %.30Lf\n", 0.0L, 0.0L);
}
printf("%.30Lf %.30Lf\n", gx, gy);
printf("%.30Lf %.30Lf\n", 0.0L, 0.0L);
return true;
}
}
return false;
}
bool solve() {
long double gr = hypot(gx, gy);
long double mn = 1e100;
for (int ii = 0; ii < 5000; ii++) {
long double x = 1;
long double y = 0;
vector<long double> vx(t);
vector<long double> vy(t);
long double theta = uniform_real_distribution<long double>(0, 2*pi)(mt);
long double c = uniform_real_distribution<long double>(1e-6, 10)(mt);
vx[0] = cos(theta) - 1;
vy[0] = sin(theta);
for (int i = 0; i < t; i++) {
long double x0 = x;
long double y0 = y;
x = x0 - y0*w + x0*v + vx[i];
y = y0 + x0*w + y0*v + vy[i];
long double r = hypot(x, y);
long double tr;
tr = gr*pow((long double)i / t, c);
long 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;
long 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: %.30Lf\n", s);
fprintf(stderr, "p: %.30Lf\n", p);
return true;
}
}
return false;
}
int main() {
int T;
cin >> T;
while (T--) {
cin >> t >> p >> w >> v >> gx >> gy;
if (!solve2()) {
solve();
}
}
}