結果

問題 No.2355 Unhappy Back Dance
ユーザー tnakao0123tnakao0123
提出日時 2023-06-29 17:50:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,398 ms / 6,000 ms
コード長 2,139 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 46,300 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 13:04:27
合計ジャッジ時間 20,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 46 ms
4,380 KB
testcase_07 AC 43 ms
4,376 KB
testcase_08 AC 115 ms
4,380 KB
testcase_09 AC 114 ms
4,376 KB
testcase_10 AC 183 ms
4,376 KB
testcase_11 AC 173 ms
4,380 KB
testcase_12 AC 125 ms
4,376 KB
testcase_13 AC 125 ms
4,380 KB
testcase_14 AC 221 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1,393 ms
4,380 KB
testcase_17 AC 1,396 ms
4,376 KB
testcase_18 AC 1,398 ms
4,376 KB
testcase_19 AC 1,397 ms
4,376 KB
testcase_20 AC 1,398 ms
4,380 KB
testcase_21 AC 580 ms
4,376 KB
testcase_22 AC 107 ms
4,376 KB
testcase_23 AC 115 ms
4,376 KB
testcase_24 AC 1,260 ms
4,376 KB
testcase_25 AC 678 ms
4,380 KB
testcase_26 AC 680 ms
4,376 KB
testcase_27 AC 584 ms
4,376 KB
testcase_28 AC 13 ms
4,384 KB
testcase_29 AC 32 ms
4,380 KB
testcase_30 AC 1,152 ms
4,376 KB
testcase_31 AC 837 ms
4,384 KB
testcase_32 AC 83 ms
4,376 KB
testcase_33 AC 475 ms
4,376 KB
testcase_34 AC 5 ms
4,380 KB
testcase_35 AC 15 ms
4,376 KB
testcase_36 AC 585 ms
4,380 KB
testcase_37 AC 312 ms
4,376 KB
testcase_38 AC 384 ms
4,380 KB
testcase_39 AC 302 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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;
}
0