結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー | k |
提出日時 | 2020-07-17 16:12:52 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 377 ms / 5,000 ms |
コード長 | 1,461 bytes |
コンパイル時間 | 2,473 ms |
コンパイル使用メモリ | 212,164 KB |
実行使用メモリ | 4,388 KB |
最終ジャッジ日時 | 2023-08-19 06:29:31 |
合計ジャッジ時間 | 10,943 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge10 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 186 ms
4,380 KB |
testcase_01 | AC | 362 ms
4,380 KB |
testcase_02 | AC | 189 ms
4,384 KB |
testcase_03 | AC | 194 ms
4,384 KB |
testcase_04 | AC | 367 ms
4,384 KB |
testcase_05 | AC | 376 ms
4,380 KB |
testcase_06 | AC | 373 ms
4,384 KB |
testcase_07 | AC | 376 ms
4,384 KB |
testcase_08 | AC | 374 ms
4,384 KB |
testcase_09 | AC | 377 ms
4,380 KB |
testcase_10 | AC | 373 ms
4,380 KB |
testcase_11 | AC | 158 ms
4,380 KB |
testcase_12 | AC | 374 ms
4,380 KB |
testcase_13 | AC | 226 ms
4,384 KB |
testcase_14 | AC | 188 ms
4,384 KB |
testcase_15 | AC | 377 ms
4,380 KB |
testcase_16 | AC | 190 ms
4,380 KB |
testcase_17 | AC | 375 ms
4,380 KB |
testcase_18 | AC | 148 ms
4,380 KB |
testcase_19 | AC | 369 ms
4,380 KB |
testcase_20 | AC | 189 ms
4,380 KB |
testcase_21 | AC | 180 ms
4,384 KB |
testcase_22 | AC | 262 ms
4,388 KB |
testcase_23 | AC | 211 ms
4,380 KB |
testcase_24 | AC | 152 ms
4,384 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); double EPS = 1e-9; bool check(vector<pair<int, int> > ps) { double gx = 0, gy = 0; for (auto p: ps) { gx += p.first; gy += p.second; } gx /= 4, gy /= 4; vector<tuple<double, int, int> > rps; for (auto p: ps) { int x = p.first; int y = p.second; double theta = atan2(y-gy, x-gx); if (theta < 0) theta += 2 * PI; rps.emplace_back(theta, x, y); } sort(rps.begin(), rps.end()); bool ck = true; REP (i, 4) { int j = (i + 1) % 4; int k = (i + 3) % 4; int x1 = get<1>(rps[j]) - get<1>(rps[i]); int y1 = get<2>(rps[j]) - get<2>(rps[i]); int x2 = get<1>(rps[k]) - get<1>(rps[i]); int y2 = get<2>(rps[k]) - get<2>(rps[i]); ck &= x1 * x2 + y1 * y2 == 0; ck &= abs(hypot(x1, y1) - hypot(x2, y2)) < EPS; } return ck; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<pair<int, int> > ps; REP (i, 3) { int x, y; cin >> x >> y; ps.emplace_back(x, y); } for (int x = -500; x <= 500; x++) { for (int y = -500; y <= 500; y++) { ps.emplace_back(x, y); if (check(ps)) { cout << x << " " << y << endl; return 0; } ps.pop_back(); } } cout << -1 << endl; return 0; }