結果
| 問題 |
No.2355 Unhappy Back Dance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-14 01:58:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,319 ms / 6,000 ms |
| コード長 | 1,811 bytes |
| コンパイル時間 | 1,933 ms |
| コンパイル使用メモリ | 204,308 KB |
| 最終ジャッジ日時 | 2025-02-13 00:23:49 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = 3.141592653589793238462643383279;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin >> N;
vector<ll> X(N), Y(N);
for (ll i = 0; i < N; ++i) {
cin >> X.at(i) >> Y.at(i);
}
//y = ax + b
//gradient = a = dy / dx
//{dx, dy}
vector<vector<pll>> gradient(N);
for (ll i = 0; i < N; ++i) {
for (ll j = 0; j < N; ++j) {
if (i == j) {
continue;
}
ll dx = X.at(i) - X.at(j), dy = Y.at(i) - Y.at(j);
if (dx == 0) {
if (dy >= 0) {
gradient.at(i).push_back({INF, 0});
}
else {
gradient.at(i).push_back({-INF, 0});
}
}
else {
// if (dx < 0) {
// dx = -dx;
// dy = -dy;
// }
ll gcd = abs(__gcd(dx, dy));
gradient.at(i).push_back({dx / gcd, dy / gcd});
}
}
}
ll ans = 0;
for (ll i = 0; i < N; ++i) {
sort(rng(gradient.at(i)));
// cout << "i" << i << "\n";
// for (ll j = 0; j < gradient.at(i).size(); ++j) {
// cout << gradient.at(i).at(j).first << " " << gradient.at(i).at(j).second << "\n";
// }
// cout << "\n";
for (ll j = 0; j < (ll)gradient.at(i).size() - 1; ++j) {
if (gradient.at(i).at(j) == gradient.at(i).at(j + 1)) {
ans += 1;
break;
}
}
}
cout << ans << "\n";
}