結果

問題 No.675 ドットちゃんたち
コンテスト
ユーザー bal4u
提出日時 2019-08-18 20:14:57
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,601 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 331 ms
コンパイル使用メモリ 40,040 KB
最終ジャッジ日時 2026-02-22 04:22:13
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yukicoder: 675 ドットちゃんたち
// 2019.8.18 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {  // 整数の入力(負数対応)
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) {  // 整数の表示(出力)
	int i; char b[30];

	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

int x[100003], y[100003], r[100003];
int X, Y, R;

void rot(int dx, int dy, int r) {
	if      (r == 0) X += dx, Y += dy;
	else if (r == 1) X -= dy, Y += dx;
	else if (r == 2) X -= dx, Y -= dy;
	else             X += dy, Y -= dx;
}

void pr(int x, int y, int r) {
	int xx, yy;
	if      (r == 0) xx =  x, yy =  y;
	else if (r == 1) xx = -y, yy =  x;
	else if (r == 2) xx = -x, yy = -y;
	else             xx =  y, yy = -x;
	out(xx), pc(' '), out(yy), pc('\n');
}

int main()
{
	int i, N, Px, Py, Nx, Ny, Nr;
	
	N = in(), Px = in(), Py = in();
	for (i = 1; i <= N; i++) {
		int cmd, dx, dy;
		cmd = gc() & 3, gc();
		if (cmd != 3) {
			if (cmd == 1) dx = in(), dy = 0;
			else          dx = 0, dy = in();
			rot(dx, dy, R);
		} else if (++R == 4) R = 0;
		x[i] = X, y[i] = Y, r[i] = R;
	}
	Nx = x[N], Ny = y[N], Nr = (4-r[N]) % 4;

	for (i = 0; i < N; i++) {
		X = 0, Y = 0;
		rot(Px, Py, r[i]);
		pr(X+Nx-x[i], Y+Ny-y[i], Nr);
	}
	return 0;
}
0