結果
| 問題 |
No.2355 Unhappy Back Dance
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-06-29 17:50:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,202 ms / 6,000 ms |
| コード長 | 2,139 bytes |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 46,792 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 08:21:22 |
| 合計ジャッジ時間 | 15,466 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2355.cc: No.2355 Unhappy Back Dance - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1500;
/* typedef */
typedef long long ll;
template <typename T>
struct Pt {
T x, y;
Pt() {}
Pt(T _x, T _y) : x(_x), y(_y) {}
Pt(const Pt<T> &p) : x(p.x), y(p.y) {}
Pt<T> operator+(const Pt<T> p) const { return Pt<T>(x + p.x, y + p.y); }
Pt<T> operator-() const { return Pt<T>(-x, -y); }
Pt<T> operator-(const Pt<T> p) const { return Pt<T>(x - p.x, y - p.y); }
Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
T dot(Pt<T> v) const { return x * v.x + y * v.y; }
T cross(Pt<T> v) const { return x * v.y - y * v.x; }
Pt<T> mid(const Pt<T> p) { return Pt<T>((x + p.x) / 2, (y + p.y) / 2); }
T d2() { return x * x + y * y; }
bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
bool operator<(const Pt<T> &pt) const {
return x < pt.x || (x == pt.x && y < pt.y);
}
T gcd(T m, T n) { // m >= 0, n >= 0
if (m < n) swap(m, n);
while (n > 0) {
T r = m % n;
m = n;
n = r;
}
return m;
}
Pt<T> &normalize() {
if (x == 0) y = (y > 0) ? 1 : (y < 0) ? -1 : 0;
else if (y == 0) x = (x > 0) ? 1 : (x < 0) ? -1 : 0;
else {
T g = gcd(abs(x), abs(y));
if (g > 1) x /= g, y /= g;
}
return *this;
}
void print() { printf("%lld,%lld ", x, y); }
};
typedef Pt<ll> pt;
/* global variables */
pt ps[MAX_N], vs[MAX_N];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld%lld", &ps[i].x, &ps[i].y);
int cnt = 0;
for (int i = 0; i < n; i++) {
int k = 0;
for (int j = 0; j < n; j++)
if (i != j) {
pt v(ps[j] - ps[i]);
v.normalize();
vs[k++] = v;
}
sort(vs, vs + k);
//ps[i].print(); for (int j = 0; j < k; j++) vs[j].print(); putchar('\n');
for (int j = 0; j + 1 < k; j++)
if (vs[j] == vs[j + 1]) {
cnt++; break;
}
}
printf("%d\n", cnt);
return 0;
}
tnakao0123