結果

問題 No.2355 Unhappy Back Dance
ユーザー norikamenorikame
提出日時 2023-08-02 22:54:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,725 ms / 6,000 ms
コード長 1,546 bytes
コンパイル時間 4,727 ms
コンパイル使用メモリ 265,640 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 22:43:51
合計ジャッジ時間 25,366 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 67 ms
5,376 KB
testcase_07 AC 63 ms
5,376 KB
testcase_08 AC 161 ms
5,376 KB
testcase_09 AC 167 ms
5,376 KB
testcase_10 AC 336 ms
5,376 KB
testcase_11 AC 348 ms
5,376 KB
testcase_12 AC 168 ms
5,376 KB
testcase_13 AC 168 ms
5,376 KB
testcase_14 AC 404 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1,630 ms
5,376 KB
testcase_17 AC 1,606 ms
5,376 KB
testcase_18 AC 1,597 ms
5,376 KB
testcase_19 AC 1,600 ms
5,376 KB
testcase_20 AC 1,725 ms
5,376 KB
testcase_21 AC 711 ms
5,376 KB
testcase_22 AC 119 ms
5,376 KB
testcase_23 AC 132 ms
5,376 KB
testcase_24 AC 1,457 ms
5,376 KB
testcase_25 AC 771 ms
5,376 KB
testcase_26 AC 776 ms
5,376 KB
testcase_27 AC 655 ms
5,376 KB
testcase_28 AC 16 ms
5,376 KB
testcase_29 AC 36 ms
5,376 KB
testcase_30 AC 1,323 ms
5,376 KB
testcase_31 AC 952 ms
5,376 KB
testcase_32 AC 97 ms
5,376 KB
testcase_33 AC 544 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
testcase_35 AC 17 ms
5,376 KB
testcase_36 AC 658 ms
5,376 KB
testcase_37 AC 356 ms
5,376 KB
testcase_38 AC 434 ms
5,376 KB
testcase_39 AC 343 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

struct fraction {
	ll num, den;
	fraction(ll num=0, ll den=1) {
		this->num = num, this->den = den;
		if (this->num == 0 && this->den == 0) return;
		if (this->den == 0) this->num /= abs(this->num);
		else if (this->num == 0) this->den /= abs(this->den);
		else {
			ll gval = gcd(abs(this->num), abs(this->den));
			this->num /= gval, this->den /= gval;
		}
	}
	bool operator<(const fraction& other) const {
		return make_pair(num, den) < make_pair(other.num, other.den);
	}
	bool operator<=(const fraction& other) const {
		return make_pair(num, den) <= make_pair(other.num, other.den);
	}
};

int main() {
	int n;
	cin >> n;
	vector<ll> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];
	if (n <= 1) {
		cout << 0 << endl;
		return 0;
	}
	unordered_set<int> st;
	rep(i, n) {
		vector<pair<fraction, int>> flst;
		rep(j, n) if (j != i) flst.emplace_back(fraction(y[j]-y[i], x[j]-x[i]), j);
		set<fraction> fst;
		rep(j, n-1) fst.insert(flst[j].first);
		for (auto& [fr, id] : flst) {
			fraction tfl(-fr.num, -fr.den);
			if (fst.find(tfl) != fst.end()) st.insert(id);
		}
	}
	cout << (int)(st.size()) << endl;
	return 0;
}
0