結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー nanasili
提出日時 2014-11-03 02:05:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,438 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 79,992 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 13:42:13
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

int main() {
  int x1, y1, x2, y2, x3, y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  int xs[] = {x1, x2, x3}, ys[] = {y1, y2, y3};

  int ax, ay;
  int dx, dy;
  for (int i = 0; i < 3; i++) {
    for (int j = i+1; j < 3; j++) {
      if (xs[j]-xs[i] != 0 || ys[j]-ys[i] != 0) {
        dx = xs[j]-xs[i];
        dy = ys[j]-ys[i];
        ax = xs[i];
        ay = ys[i];

        for (int p = 0; p < 2; p++) {
          int cnt = 0;
          int tx, ty;
        
          for (int k = 0; k < 4; k++) {
            ax += dx; ay += dy;
            bool yes = false;
            for (int l = 0; l < 3; l++) {
              if (ax == xs[l] && ay == ys[l]) yes = true;
            }
            if (!yes) {
              tx = ax; ty = ay;
              cnt++;
            }
            if (p == 0) dx = -dx;
            if (p == 1) dy = -dy;
            swap(dx, dy);
          }
          if (cnt == 1) {
            cout << tx << " " << ty << endl;
            return 0;
          }

        }
      }
    }
  }

  cout << -1 << endl;
}
0