結果

問題 No.1041 直線大学
ユーザー motmot
提出日時 2020-05-01 21:42:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 2,019 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 79,000 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 08:35:09
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 13 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int gcd(int x, int y){
    int v0 = x, v1 = y, v2 = x % y;
    while(v2!=0){
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    }
    return v1;
}

int main() {
    int N;
    cin>>N;
    vector<int> X(N), Y(N);
    for(int i=0;i<N;++i){
        cin>>X[i]>>Y[i];
    }
    int x, y, xx, yy;
    int tmp;
    int tmpans;
    int ans = 0;
    for(int i=0;i<N;++i){
        for(int j=0;j<i;++j){
            x = X[i] - X[j];
            y = Y[i] - Y[j];
            if((x!=0) & (y!=0)){
                tmp = gcd(x, y);
                x /= tmp;
                y /= tmp;
                tmpans = 2;
                for(int k=0;k<N;++k){
                    if((k==i) | (k==j)) continue;
                    xx = X[i] - X[k];
                    yy = Y[i] - Y[k];
                    if((xx==0) | (yy==0)) continue;
                    tmp = gcd(xx, yy);
                    xx /= tmp;
                    yy /= tmp;
                    if(((x==xx) & (y==yy)) | ((x==-xx) & (y==-yy))) tmpans++;
                }
                if(ans < tmpans) ans = tmpans;
            }
            else if(x==0){
                tmpans = 2;
                for(int k=0;k<N;++k){
                    if((k==i) | (k==j)) continue;
                    xx = X[i] - X[k];
                    if(xx==0)tmpans++;
                }
                if(ans < tmpans) ans = tmpans;
            }
            else {
                tmpans = 2;
                for(int k=0;k<N;++k){
                    if((k==i) | (k==j)) continue;
                    yy = Y[i] - Y[k];
                    if(yy==0) tmpans++;
                }
                if(ans < tmpans) ans = tmpans;
            }
        }
    }
    cout<<ans<<endl;
}

0