結果

問題 No.675 ドットちゃんたち
ユーザー PachicobuePachicobue
提出日時 2018-09-14 18:10:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,499 bytes
コンパイル時間 2,709 ms
コンパイル使用メモリ 205,980 KB
実行使用メモリ 11,588 KB
最終ジャッジ日時 2023-09-19 09:22:15
合計ジャッジ時間 7,061 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N, Px, Py;
    std::cin >> N >> Px >> Py;
    int rot = 0, dx = 0, dy = 0;
    auto move = [&](const int Dx, const int Dy) {
        if (rot == 0) {
            dx += Dx, dy += Dy;
        } else if (rot == 1) {
            dx += Dy, dy -= Dx;
        } else if (rot == 2) {
            dx -= Dx, dy -= Dy;
        } else {
            dx -= Dy, dy += Dx;
        }
    };
    std::string ans;
    auto answer = [&]() {
        int X, Y;
        if (rot == 0) {
            X = Px, Y = Py;
        } else if (rot == 1) {
            X = Py, Y = -Px;
        } else if (rot == 2) {
            X = -Px, Y = -Py;
        } else {
            X = -Py, Y = Px;
        }
        ans = std::to_string(X + dx) + " " + std::to_string(Y + dy) + "\n" + ans;
    };
    using P = std::pair<int, int>;
    using PP = std::pair<bool, P>;
    std::vector<PP> com;
    for (int i = 0; i < N; i++) {
        int Com, Dx = 0, Dy = 0;
        std::cin >> Com;
        if (Com == 1) {
            std::cin >> Dx;
        } else if (Com == 2) {
            std::cin >> Dy;
        }
        com.push_back({Com == 3, {Dx, Dy}});
    }
    std::reverse(com.begin(), com.end());
    for (const auto& c : com) {
        if (c.first) {
            (rot += 1) %= 4;
        } else {
            move(c.second.first, c.second.second);
        }
        answer();
    }
    std::cout << ans << std::endl;
    return 0;
}
0