結果
問題 | No.2355 Unhappy Back Dance |
ユーザー | 👑 hos.lyric |
提出日時 | 2023-06-16 21:39:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 594 ms / 6,000 ms |
コード長 | 5,306 bytes |
コンパイル時間 | 1,442 ms |
コンパイル使用メモリ | 117,320 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 13:26:34 |
合計ジャッジ時間 | 10,485 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#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; }