結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー nanasilinanasili
提出日時 2014-11-03 02:05:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,438 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 78,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:04:49
合計ジャッジ時間 1,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 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 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 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 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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