結果

問題 No.675 ドットちゃんたち
ユーザー koyoprokoyopro
提出日時 2020-01-03 23:22:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,264 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 145,120 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-08-14 19:42:34
合計ジャッジ時間 4,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 29 ms
4,892 KB
testcase_06 AC 58 ms
4,724 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

int N,X,Y;
struct Order{int c; int v;};


struct Pos {
    int x, y;
    Pos(){};
    Pos(int _x, int _y): x(_x), y(_y){};
    
    Pos operator * (int t) {
        return Pos(t * x, t * y);
    }
    Pos operator + (Pos q) {
        return Pos(x + q.x, y + q.y);
    }
    Pos operator - (Pos q) {
        return Pos(x - q.x, y - q.y);
    }
    int dot(Pos q) {
        return x * q.x + y * q.y;
    }
    int det(Pos q) {
        return x * q.y - y * q.x;
    }
    bool operator == (Pos q) {
        return (x == q.x) && (y == q.y);
    }
    void rotate() {
        int tmp = y;
        y = -x;
        x = tmp;
    }
    void rotate2() {
        int tmp = x;
        x = -y;
        y = tmp;
    }
};

signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin>>N>>X>>Y;
    
    vector<Order> O(N);
    int c=0,v=0;
    Pos pos(X, Y);
    Pos c1(1, 0);
    Pos c2(0, 1);
    REP(i,N) {
        cin>>c;
        if (c<3) cin>>v;
        if (c == 1) {
            pos = pos + c1 * v;
        }
        if (c==2) {
            pos = pos + c2 * v;
        }
        if (c==3){
            pos.rotate();
            c1.rotate();
            c2.rotate();
        }
        O[i].c = c;
        O[i].v = v;
    }
    c1 = c1 * -1;
    c2 = c2 * -1;
    REP(i,N) {
        out("%lld %lld\n", pos.x, pos.y);
        auto o = O[i];
        if (o.c == 1) {
            pos = pos + c1 * o.v;
        }
        if (o.c==2) {
            pos = pos + c2 * o.v;
        }
        if (o.c==3){
            pos.rotate2();
            c1.rotate2();
            c2.rotate2();
        }
    }
    
    return 0;
}
0