結果

問題 No.675 ドットちゃんたち
ユーザー finefine
提出日時 2018-04-13 23:16:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 1,660 ms
コンパイル使用メモリ 167,812 KB
実行使用メモリ 6,588 KB
最終ジャッジ日時 2023-09-09 04:47:51
合計ジャッジ時間 4,466 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 147 ms
6,420 KB
testcase_06 AC 158 ms
6,424 KB
testcase_07 AC 140 ms
6,276 KB
testcase_08 AC 150 ms
6,588 KB
testcase_09 AC 156 ms
6,416 KB
testcase_10 AC 154 ms
6,360 KB
testcase_11 AC 152 ms
6,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll px, py;
    cin >> n >> px >> py;
    vector<ll> mx(n, 0), my(n, 0);
    vector<ll> ax(n, px), ay(n, py);
    vector<int> cnt(n + 1, 0);
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        mx[i] = px - ax[0];
        my[i] = py - ay[0];
        if (c == 1) {
            ll dx;
            cin >> dx;
            ax[0] += dx;
        } else if (c == 2) {
            ll dy;
            cin >> dy;
            ay[0] += dy;
        } else if (c == 3) {
            cnt[0]++;
            cnt[i + 1]--;
            ll tmp = ax[0];
            ax[0] = ay[0];
            ay[0] = -tmp;
        }
    }

    for (int i = 1; i < n; i++) {
        cnt[i] += cnt[i - 1];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < cnt[i] % 4; j++) {
            ll tmp = mx[i];
            mx[i] = my[i];
            my[i] = -tmp;
        }

        ax[i] = mx[i] + ax[0];
        ay[i] = my[i] + ay[0];
        cout << ax[i] << " " << ay[i] << endl;
    }

    return 0;
}
0