結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー | xuzijian629 |
提出日時 | 2018-10-29 17:48:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,620 bytes |
コンパイル時間 | 2,238 ms |
コンパイル使用メモリ | 205,084 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-29 23:01:51 |
合計ジャッジ時間 | 3,076 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 8 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 8 ms
5,376 KB |
testcase_09 | AC | 8 ms
5,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 7 ms
5,376 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 4 ms
5,376 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using vi = vector<i64>; using vvi = vector<vi>; struct Point { int x, y; Point operator+(const Point rhs) { return {x + rhs.x, y + rhs.y}; } Point operator/(const int k) { return {x / k, y / k}; } int dist(const Point rhs) { return abs(x - rhs.x) + abs(y - rhs.y); } bool operator==(const Point rhs) { return x == rhs.x && y == rhs.y; } }; bool isSquare(vector<Point> points) { for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { if (points[i] == points[j]) { return false; } } } for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { Point G = (points[i] + points[j]) / 2; int ok = 1; int D = points[0].dist(G); for (int k = 1; k < 4; k++) { if (D != points[k].dist(G)) { ok = 0; } } if (ok) { return true; } } } return false; } int main() { vector<Point> hoge; for (int i = 0; i < 3; i++) { int x, y; cin >> x >> y; hoge.push_back({2 * x, 2 * y}); } for (int i = -100; i <= 100; i++) { for (int j = -100; j <= 100; j++) { vector<Point> fuga(hoge); fuga.push_back({2 * i, 2 * j}); if (isSquare(fuga)) { cout << i << " " << j << endl; return 0; } } } cout << -1 << endl; }