結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2018-01-15 14:59:25 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 1,798 bytes |
コンパイル時間 | 919 ms |
コンパイル使用メモリ | 85,040 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 02:35:43 |
合計ジャッジ時間 | 1,964 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <cstring>#include <math.h>#include <cmath>#include <limits.h>#include <map>#include <set>#include <queue>#include <algorithm>#include <functional>#include <stdio.h>using namespace std;long long MOD = 1000000007;int main() {vector< pair<int,int> > P;for ( int i = 0; i < 3; i++ ) {int x,y;cin >> x >> y;P.push_back(make_pair( x,y ));}vector<int> V = {0,1,2,3};for ( int x = -200; x <= 200; x++ ) {for ( int y = -200; y <= 200; y++ ) {bool ng = false;for ( int i = 0; i < 3; i++ ) {if ( x == P[i].first && y == P[i].second ) { ng = true; }}if ( ng ) { continue; }P.push_back(make_pair(x,y) );bool is_ok = true;do {int p = ( P[V[0]].first-P[V[1]].first ) * ( P[V[2]].first-P[V[3]].first ) +( P[V[0]].second-P[V[1]].second ) * ( P[V[2]].second-P[V[3]].second );int d1 = ( P[V[0]].first-P[V[1]].first ) * ( P[V[0]].first-P[V[1]].first ) +( P[V[0]].second-P[V[1]].second ) * ( P[V[0]].second-P[V[1]].second );int d2 = ( P[V[2]].first-P[V[3]].first ) * ( P[V[2]].first-P[V[3]].first ) +( P[V[2]].second-P[V[3]].second ) * ( P[V[2]].second-P[V[3]].second );if ( d1 != d2 ) { is_ok = false; }if ( p != 0 && p != d1 && -p != d1 ) { is_ok = false; }} while ( next_permutation(V.begin(),V.end()) );if ( is_ok ) { cout << x << " " << y << endl; return 0; }P.pop_back();}}cout << -1 << endl;return 0;}