結果

問題 No.2355 Unhappy Back Dance
ユーザー 👑 hos.lyrichos.lyric
提出日時 2023-06-16 21:39:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 598 ms / 6,000 ms
コード長 5,306 bytes
コンパイル時間 1,259 ms
コンパイル使用メモリ 113,764 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-06 19:01:41
合計ジャッジ時間 11,367 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 413 ms
4,384 KB
testcase_07 AC 376 ms
4,380 KB
testcase_08 AC 413 ms
4,380 KB
testcase_09 AC 598 ms
4,380 KB
testcase_10 AC 415 ms
4,380 KB
testcase_11 AC 381 ms
4,384 KB
testcase_12 AC 448 ms
4,380 KB
testcase_13 AC 441 ms
4,384 KB
testcase_14 AC 462 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 395 ms
4,380 KB
testcase_17 AC 392 ms
4,380 KB
testcase_18 AC 392 ms
4,384 KB
testcase_19 AC 390 ms
4,384 KB
testcase_20 AC 392 ms
4,384 KB
testcase_21 AC 138 ms
4,380 KB
testcase_22 AC 23 ms
4,384 KB
testcase_23 AC 26 ms
4,380 KB
testcase_24 AC 349 ms
4,380 KB
testcase_25 AC 186 ms
4,384 KB
testcase_26 AC 186 ms
4,388 KB
testcase_27 AC 137 ms
4,380 KB
testcase_28 AC 4 ms
4,384 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 318 ms
4,384 KB
testcase_31 AC 229 ms
4,380 KB
testcase_32 AC 18 ms
4,384 KB
testcase_33 AC 111 ms
4,384 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 4 ms
4,384 KB
testcase_36 AC 139 ms
4,384 KB
testcase_37 AC 73 ms
4,384 KB
testcase_38 AC 87 ms
4,380 KB
testcase_39 AC 70 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

// using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


#ifndef LIBRA_OTHER_INT128_H_
#define LIBRA_OTHER_INT128_H_

#include <stdio.h>
#include <iostream>

constexpr unsigned __int128 toUInt128(const char *s) {
  unsigned __int128 x = 0;
  for (; *s; ++s) x = x * 10 + (*s - '0');
  return x;
}
constexpr __int128 toInt128(const char *s) {
  if (*s == '-') return -toInt128(s + 1);
  __int128 x = 0;
  for (; *s; ++s) x = x * 10 + (*s - '0');
  return x;
}
unsigned __int128 inUInt128() {
  static char buf[41];
  scanf("%s", buf);
  return toUInt128(buf);
}
__int128 inInt128() {
  static char buf[41];
  scanf("%s", buf);
  return toInt128(buf);
}

void out(unsigned __int128 x) {
  static char buf[41];
  int len = 0;
  do { buf[len++] = '0' + static_cast<int>(x % 10); } while (x /= 10);
  for (int i = len; --i >= 0; ) putchar(buf[i]);
}
void out(__int128 x) {
  if (x < 0) {
    putchar('-');
    out(-static_cast<unsigned __int128>(x));
  } else {
    out(static_cast<unsigned __int128>(x));
  }
}
std::ostream &operator<<(std::ostream &os, unsigned __int128 x) {
  static char buf[41];
  int len = 0;
  do { buf[len++] = '0' + static_cast<int>(x % 10); } while (x /= 10);
  for (int i = len; --i >= 0; ) os << buf[i];
  return os;
}
std::ostream &operator<<(std::ostream &os, __int128 x) {
  if (x < 0) {
    os << '-' << -static_cast<unsigned __int128>(x);
  } else {
    os << static_cast<unsigned __int128>(x);
  }
  return os;
}

#endif  // LIBRA_OTHER_INT128_H_


using Int = __int128;

int sig(Int r) { return (r < 0) ? -1 : (r > 0) ? +1 : 0; }
struct Pt {
  Int x, y;
  Pt() : x(0), y(0) {}
  Pt(Int x_, Int y_) : x(x_), y(y_) {}
  Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
  Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
  Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
  Pt operator+() const { return Pt(+x, +y); }
  Pt operator-() const { return Pt(-x, -y); }
  Pt operator*(const Int &k) const { return Pt(x * k, y * k); }
  Pt operator/(const Int &k) const { return Pt(x / k, y / k); }
  friend Pt operator*(const Int &k, const Pt &a) { return Pt(k * a.x, k * a.y); }
  Pt &operator+=(const Pt &a) { x += a.x; y += a.y; return *this; }
  Pt &operator-=(const Pt &a) { x -= a.x; y -= a.y; return *this; }
  Pt &operator*=(const Pt &a) { return *this = *this * a; }
  Pt &operator*=(const Int &k) { x *= k; y *= k; return *this; }
  Int abs2() const { return x * x + y * y; }
  Int dot(const Pt &a) const { return x * a.x + y * a.y; }
  Int det(const Pt &a) const { return x * a.y - y * a.x; }
  bool operator==(const Pt &a) const { return (x == a.x && y == a.y); }
  bool operator<(const Pt &a) const { return (x < a.x || (x == a.x && y < a.y)); }
  friend ostream &operator<<(ostream &os, const Pt &a) { os << "(" << a.x << ", " << a.y << ")"; return os; }
};
Int tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }

// [0, 2 PI)
int cmpArg(const Pt &a, const Pt &b) {
  const int sa = (a.y > 0) ? 1 : (a.y < 0) ? 3 : (a.x > 0) ? 0 : 2;
  const int sb = (b.y > 0) ? 1 : (b.y < 0) ? 3 : (b.x > 0) ? 0 : 2;
  return (sa < sb) ? -1 : (sa > sb) ? +1 : sig(b.det(a));
}


int N;
vector<Pt> P;

int main() {
  for (; ~scanf("%d", &N); ) {
    P.resize(N);
    for (int u = 0; u < N; ++u) {
      P[u].x = inInt128();
      P[u].y = inInt128();
    }
    
    vector<int> ans(N, 0);
    for (int u = 0; u < N; ++u) {
      using Entry = pair<Pt, int>;
      vector<Entry> es;
      for (int v = 0; v < N; ++v) if (u != v) {
        es.emplace_back(P[v] - P[u], v);
      }
      sort(es.begin(), es.end(), [&](const Entry &e0, const Entry &e1) -> bool {
        const int s = cmpArg(e0.first, e1.first);
        if (s) return (s < 0);
        return (e0.first.abs2() < e1.first.abs2());
      });
      for (int i = 0, j; i < N - 1; i = j) {
        for (j = i + 1; j < N - 1 && !cmpArg(es[i].first, es[j].first); ++j) {}
        if (j - i >= 2) {
          ans[u] = 1;
        }
      }
    }
// cerr<<"ans = "<<ans<<endl;
    
    int ansCnt = 0;
    for (int u = 0; u < N; ++u) if (ans[u]) {
      ++ansCnt;
    }
    printf("%d\n", ansCnt);
  }
  return 0;
}
0