結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー IL_mstaIL_msta
提出日時 2015-06-24 08:47:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,252 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 84,368 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:13:46
合計ジャッジ時間 1,440 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int plen(int x1,int y1,int x2,int y2){
	return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}

bool solve(int Px,int Py,int X1,int Y1,int X2,int Y2,int* aX,int*aY){
	bool ans = false;
	if( plen(Px,Py,X1,Y1) == plen(Px,Py,X2,Y2) ){
		if( (X1-Px)*(X2-Px) + (Y1-Py)*(Y2-Py) == 0){
			*aX = X2+X1-Px;
			*aY = Y2+Y1-Py;
			ans = true;
		}
	}
	return ans;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
	
	int ansX,ansY;
	bool ansf = false;
	int X[3],Y[3];
	rep(i,3){
		cin>>X[i]>>Y[i];
	}
	
	for(int i=0;i<3;++i)
	{
		ansf = solve(X[i%3],Y[i%3],X[(i+1)%3],Y[(i+1)%3],X[(i+2)%3],Y[(i+2)%3],
			&ansX,&ansY);
		if( ansf == true ){
			cout << ansX << " " << ansY << endl;
			break;
		}
	}

	if( ansf == false){
		cout << -1 << endl;
	}
	
	return 0;
}
0