結果

問題 No.2355 Unhappy Back Dance
ユーザー Heart_BlueHeart_Blue
提出日時 2023-06-16 22:50:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,001 ms / 6,000 ms
コード長 1,724 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 138,236 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-06 21:26:35
合計ジャッジ時間 14,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 26 ms
4,380 KB
testcase_07 AC 61 ms
4,384 KB
testcase_08 AC 68 ms
4,384 KB
testcase_09 AC 68 ms
4,380 KB
testcase_10 AC 310 ms
4,380 KB
testcase_11 AC 312 ms
4,380 KB
testcase_12 AC 69 ms
4,384 KB
testcase_13 AC 70 ms
4,380 KB
testcase_14 AC 344 ms
4,380 KB
testcase_15 AC 1 ms
4,388 KB
testcase_16 AC 998 ms
4,384 KB
testcase_17 AC 1,001 ms
4,380 KB
testcase_18 AC 975 ms
4,380 KB
testcase_19 AC 991 ms
4,384 KB
testcase_20 AC 995 ms
4,384 KB
testcase_21 AC 401 ms
4,380 KB
testcase_22 AC 70 ms
4,380 KB
testcase_23 AC 77 ms
4,384 KB
testcase_24 AC 873 ms
4,384 KB
testcase_25 AC 472 ms
4,384 KB
testcase_26 AC 472 ms
4,380 KB
testcase_27 AC 411 ms
4,380 KB
testcase_28 AC 10 ms
4,380 KB
testcase_29 AC 22 ms
4,384 KB
testcase_30 AC 821 ms
4,384 KB
testcase_31 AC 586 ms
4,384 KB
testcase_32 AC 57 ms
4,380 KB
testcase_33 AC 340 ms
4,380 KB
testcase_34 AC 4 ms
4,384 KB
testcase_35 AC 11 ms
4,384 KB
testcase_36 AC 415 ms
4,384 KB
testcase_37 AC 220 ms
4,380 KB
testcase_38 AC 269 ms
4,384 KB
testcase_39 AC 204 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;
int flag[N];
pair<LL, LL> vp[N];
map<pair<LL, LL>, vector<int>> mc;
pair<LL, LL> check(pair<LL, LL>& p1, pair<LL, LL>& p2)
{
	LL a = p2.first - p1.first;
	LL b = p2.second - p1.second;
	LL g = gcd(abs(a), abs(b));
	a /= g;
	b /= g;
	if (a < 0) a = -a, b = -b;
	if (a == 0) b = abs(b);
	return { a,b };
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld%lld", &vp[i].first, &vp[i].second);
	for (int i = 1; i <= n; i++)
	{
		mc.clear();
		for (int j = 1; j <= n; j++)
		{
			if (i == j) continue;
			mc[check(vp[i], vp[j])].push_back(j);
		}
		for (auto& [x, v] : mc)
		{
			if (v.size() == 1) continue;
			if (v.size() > 2)
			{
				for (auto& y : v)
					flag[y] = 1;
				continue;
			}
			vector<pair<pair<LL, LL>, int>> key;
			for (int j = 0; j < v.size(); j++)
			{
				key.emplace_back(vp[v[j]], v[j]);
			}
			key.emplace_back(vp[i], i);
			sort(key.begin(), key.end());
			flag[key.front().second] = 1;
			flag[key.back().second] = 1;

		}
	}
	printf("%d\n", count(flag, flag + n + 1, 1));
	return 0;
}
0