Submission #00028


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <bits/stdc++.h>
using namespace std;
struct Point {
int x, y;
bool operator<(const Point &r) const {
if(x == r.x) return y < r.y;
else return x < r.x;
}
};
int dist(Point a, Point b) {
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
bool is_square(Point a, Point b, Point c, Point d) {
if(!(dist(a, b) == dist(a, c) && dist(d, b) == dist(d, c))) {
return false;
}
if(!(dist(a, d) == dist(b, c))) {
return false;
}
return true;
}
int main() {
int n;
Point p[3000];
map<Point, bool> graph;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> p[i].x >> p[i].y;
graph[(Point){ p[i].x, p[i].y }] = true;
}
sort(p, p + n);
int s = 0;
for(int i = 0; i < n; ++i) {
for(int j = i + 1; j < n; ++j) {
/*
if(is_square(p[i], p[j], p[k], p[l])) {
s = max(s, dist(p[i], p[j]));
}
*/
Point c, d;
if(p[i].y < p[j].y) {
c = (Point){ p[j].x + (p[j].y - p[i].y), p[j].y - (p[j].x - p[i].x) };
d = (Point){ p[i].x + (p[j].y - p[i].y), p[i].y - (p[j].x - p[i].x) };
} else {
c = (Point){ p[i].x + (p[i].y - p[j].y), p[i].y + (p[j].x - p[i].x) };
d = (Point){ p[j].x + (p[i].y - p[j].y), p[j].y + (p[j].x - p[i].x) };
}
if(graph.count(c) && graph.count(d)) {
s = max(s, dist(p[i], p[j]));
}
}
}
cout << s << endl;
}

ステータス

項目 データ
問題 0003 - 最古の遺跡
ユーザー名 ei1503
投稿日時 2017-02-03 18:15:56
言語 C++11
状態 Accepted
得点 100
ソースコード長 1658 Byte
最大実行時間 281 ms
最大メモリ使用量 856 KB

セット

セット 得点 Cases
1 set1 10 / 10 *in01
2 set2 10 / 10 *in02
3 set3 10 / 10 *in03
4 set4 10 / 10 *in04
5 set5 10 / 10 *in05
6 set6 10 / 10 *in06
7 set7 10 / 10 *in07
8 set8 10 / 10 *in08
9 set9 10 / 10 *in09
10 set10 10 / 10 *in10

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2007-ho-t3-in01 AC 21 ms 480 KB
1
2007-ho-t3-in02 AC 16 ms 452 KB
2
2007-ho-t3-in03 AC 18 ms 544 KB
3
2007-ho-t3-in04 AC 28 ms 644 KB
4
2007-ho-t3-in05 AC 57 ms 588 KB
5
2007-ho-t3-in06 AC 19 ms 656 KB
6
2007-ho-t3-in07 AC 251 ms 856 KB
7
2007-ho-t3-in08 AC 281 ms 756 KB
8
2007-ho-t3-in09 AC 215 ms 784 KB
9
2007-ho-t3-in10 AC 232 ms 816 KB
10