結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー ty70
提出日時 2015-06-09 03:56:48
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,770 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 92,492 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 13:50:04
合計ジャッジ時間 1,706 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28
#define EPS 1e-8
// 2
#define EQ(a,b) (abs(abs(a)-abs(b)) < EPS)
using namespace std;
typedef long long ll;
typedef complex<double> P;
// (dot product) : a⋅b = |a||b|cosθ
double dot(P a, P b) {
return (a.real() * b.real() + a.imag() * b.imag());
}
P is_square (P p_base, P p1, P p2 ){
p1 -= p_base;
p2 -= p_base;
if (EQ(p1, p2 ) && abs(dot(p1, p2 ) ) < EPS ){
P res = p1 + p2;
res += p_base;
return res;
} // end if
return P (INF, INF );
}
int main()
{
ios_base::sync_with_stdio(0);
P pos[3];
rep (i, 3 ){
int x, y; cin >> x >> y;
pos[i] = P (x, y );
} // end rep
P ans[3];
P res = P(INF, INF );
rep (i, 3 ){
ans[i] = is_square (pos[i%3], pos[(i+1)%3], pos[(i+2)%3] );
if (ans[i].real() != INF ){
res = ans[i]; break;
} // end if
} // end rep
if (res.real() != INF )
cout << res.real() << ' ' << res.imag() << endl;
else
cout << -1 << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0