結果

問題 No.1041 直線大学
ユーザー T.StreamT.Stream
提出日時 2020-05-16 11:44:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 195,440 KB
最終ジャッジ日時 2025-01-10 12:23:08
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int n,i,j,k,cur,ans;
	cin >> n;
	vector<pair<int,int>> x(n);
	for(i=0; i<n; i++){
		cin >> x[i].first >> x[i].second;
	}
	
	ans=2;
	double tanga,tangb;
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			cur=0;
			if(x[i].second==x[j].second){
				for(k=0; k<n; k++){
					if(x[k].second==x[i].second) cur++;
				}
			}else{
				tanga=double(x[j].first-x[i].first)/double(x[j].second-x[i].second);
				cur=1;
				for(k=0; k<n; k++){
					if(x[k].second-x[i].second==0){
						continue;
					}
					tangb=double(x[k].first-x[i].first)/double(x[k].second-x[i].second);
					if(abs(tangb-tanga)<0.0000001){
						cur++;
					}
				}
			}
			ans=max(cur,ans);
		}
	}
	cout << ans << endl;
	return 0;
}
0