結果

問題 No.620 ぐるぐるぐるりん
ユーザー PachicobuePachicobue
提出日時 2017-12-20 18:17:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,788 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 201,920 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 10:57:16
合計ジャッジ時間 4,695 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;
constexpr ld PI = static_cast<ld>(3.1415926535898);

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

struct Vec {
    Vec() : dx{0}, dy{0} {}
    Vec(const ld dx, const ld dy) : dx{dx}, dy{dy} {}
    ld dx;
    ld dy;
    Vec rotate(const ld theta) const
    {
        Vec ans;
        ans.dx = cos(theta) * dx - sin(theta) * dy;
        ans.dy = sin(theta) * dx + cos(theta) * dy;
        return ans;
    }
    Vec operator*(const ld x) const
    {
        Vec ans = *this;
        ans.dx *= x;
        ans.dy *= x;
        return ans;
    }
    ld norm() const
    {
        return hypot(dx, dy);
    }
    void normalize()
    {
        const ld n = norm();
        dx /= n;
        dy /= n;
    }
};
ostream& operator<<(ostream& os, const Vec& v)
{
    os << "(" << v.dx << "," << v.dy << ")";
    return os;
}


//#define LOCAL_DEBUG 1

int main()
{
    int N;
    cin >> N;
    for (int q = 0; q < N; q++) {
        int T;
        cin >> T;
        ld p, omega, v, gx, gy;
        cin >> p >> omega >> v >> gx >> gy;
        const ld l = hypot(omega, (ld)(1 + v));
        const ld theta = (1 + v > 0 ? atan(omega / (1 + v)) : PI + atan(omega / (1 + v)));
        Vec g{gx - pow(l, T) * cos(T * theta), gy - pow(l, T) * sin(T * theta)};
        ld F = 0;
        for (int i = 0; i < T; i++) {
            if (l < 1) {
                F += pow(l, 2 * T - 2 - 2 * i);
            } else {
                F += pow(l, 2 * i);
            }
        }
        ld sum = 0;
        vector<Vec> u(T);
        for (int i = 0; i < T; i++) {
            const Vec v = g.rotate((i + 1 - T) * theta) * (pow(l, T - 1 - i) / F);
            u[i] = v;
            sum += v.norm() * v.norm();
            cout << fixed << setprecision(50) << v.dx << " " << v.dy << endl;
        }
#ifdef LOCAL_DEBUG
        cerr << "# HP #" << endl;
        cerr << fixed << setprecision(15) << p << endl;
        cerr << "# used #" << endl;
        cerr << fixed << setprecision(15) << sum << endl;
        const string name = "data_" + to_string(T) + "_" + to_string(p) + "_" + to_string(omega) + "_" + to_string(v) + "_" + to_string(gx) + "_" + to_string(gy);
        ofstream fout(name);
        ld xpos = 1;
        ld ypos = 0;
        fout << fixed << setprecision(15) << xpos << " " << ypos << endl;
        for (int i = 0; i < T; i++) {
            ld x = xpos * (1 + v) - ypos * omega + u[i].dx;
            ld y = ypos * (1 + v) + xpos * omega + u[i].dy;
            fout << x << " " << y << endl;
            xpos = x;
            ypos = y;
        }
        cerr << "# actual goal#" << endl;
        cerr << fixed << setprecision(15) << gx << " " << gy << endl;
        cerr << "# result #" << endl;
        cerr << fixed << setprecision(15) << xpos << " " << ypos << endl;
        fout.close();
        FILE* fp = popen("gnuplot -persist", "w");
        if (not fp) {
            cerr << "udwiqhduqdhwiodhqoidw" << endl;
        } else {
            fprintf(fp, "set terminal png\n");
            fprintf(fp, "set output \"%s.png\"\n", name.c_str());
            fprintf(fp, "plot \"%s\" w lp\n", name.c_str());
            fflush(fp);
            fclose(fp);
        }
#endif
    }
    return 0;
}
0