結果

問題 No.1041 直線大学
ユーザー phsplsphspls
提出日時 2020-05-03 02:08:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,717 bytes
コンパイル時間 1,783 ms
コンパイル使用メモリ 185,656 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 00:14:54
合計ジャッジ時間 2,884 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

int gcd(int a, int b) {
    if(b == 0) return a;
    if(a % b == 0) return b;
    return gcd(b, a%b);
}

void putVal(int x, int y, int a1, int a2, map<tuple<int, int, int>, set<int>> &result) {
    tuple<int, int, int> key = make_tuple(a1, x, y);
    if(result.find(key) == result.end()) {
        result[key] = set<int>();
    }
    result[key].insert(a2);
}

int main() {
    int n;
    cin >> n;
    vector<pair<int , int>> coords;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        coords.push_back(make_pair(x, y));
    }

    //x, y, coord
    map<tuple<int, int, int>, set<int>> result;
    rep(i, n) {
        pair<int, int> a1 = coords[i];
        int a1f = a1.first;
        int a1s = a1.second;
        rep(j, n) {
            if(i == j) continue;
            pair<int, int> a2 = coords[j];
            int a2f = a2.first;
            int a2s = a2.second;
            if(a1f < a2f) {
                int x = a2f - a1f;
                int y = a2s - a1s;
                int gcdval = gcd(max(abs(x), abs(y)), min(abs(x), abs(y)));
                putVal(x / gcdval, y / gcdval, i, j, result);
            } else if(a1f == a2f) {
                putVal(0, 0, i, j, result);
            } else {
                int x = a1f - a2f;
                int y = a1s - a2s;
                int gcdval = gcd(max(abs(x), abs(y)), min(abs(x), abs(y)));
                putVal(x / gcdval, y / gcdval, i, j, result);
            }
        }
    }
    int maxval = 0;
    for(auto a: result) {
        maxval = max(maxval, (int)a.second.size() + 1);
    }
    cout << maxval << "\n";
}
0