結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー myantamyanta
提出日時 2017-05-11 01:56:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 931 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 26,480 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-13 10:09:22
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>


class pos_t
{
public:
	int x, y;
	bool operator==(pos_t& rhs)
	{
		return (x==rhs.x && y==rhs.y);
	}
	pos_t operator+(pos_t& rhs)
	{
		pos_t ret;
		ret.x=x+rhs.x;
		ret.y=y+rhs.y;
		return ret;
	}
	pos_t operator-(pos_t& rhs)
	{
		pos_t ret;
		ret.x=x-rhs.x;
		ret.y=y-rhs.y;
		return ret;
	}
	void print(void)
	{
		printf("%d %d\n", x, y);
	}
};


int main(void)
{
	pos_t p[2], o, a, b;
	int i;

	while(scanf("%d%d", &o.x, &o.y)==2)
	{
		for(i=0;i<2;i++)
		{
			scanf("%d%d", &p[i].x, &p[i].y);
			p[i]=p[i]-o;
		}
		a=p[0];
		b=p[1];
		if((a.x==b.y && a.y==-b.x) || (a.x==-b.y && a.y==b.x))
		{
			(a+b+o).print();
			continue;
		}

		a=p[0]-p[1];
		b=p[1];
		if((a.x==b.y && a.y==-b.x) || (a.x==-b.y && a.y==b.x))
		{
			(a+o).print();
			continue;
		}
		a=p[1]-p[0];
		b=p[0];
		if((a.x==b.y && a.y==-b.x) || (a.x==-b.y && a.y==b.x))
		{
			(a+o).print();
			continue;
		}
		printf("-1\n");
	}

	return 0;
}
0