結果

問題 No.849 yuki国の分割統治
ユーザー finefine
提出日時 2019-07-05 23:29:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 176,036 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-04-16 08:10:43
合計ジャッジ時間 4,824 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 49 ms
6,940 KB
testcase_08 AC 67 ms
6,944 KB
testcase_09 AC 63 ms
6,944 KB
testcase_10 AC 58 ms
6,944 KB
testcase_11 AC 57 ms
6,944 KB
testcase_12 AC 52 ms
6,944 KB
testcase_13 AC 71 ms
6,940 KB
testcase_14 AC 64 ms
6,944 KB
testcase_15 AC 61 ms
6,940 KB
testcase_16 AC 94 ms
8,576 KB
testcase_17 AC 57 ms
6,940 KB
testcase_18 AC 101 ms
8,832 KB
testcase_19 AC 61 ms
6,940 KB
testcase_20 AC 82 ms
7,168 KB
testcase_21 AC 40 ms
6,944 KB
testcase_22 AC 85 ms
8,960 KB
testcase_23 AC 77 ms
8,192 KB
testcase_24 AC 53 ms
6,944 KB
testcase_25 AC 105 ms
10,112 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = __int128;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;

const ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long aa, bb, cc, dd;
    cin >> aa >> bb >> cc >> dd;
    __int128 a = aa, b = bb, c = cc, d = dd;
    __int128 m = a * d - b * c;
    if (m == 0) { 
        //assert(false);
        __int128 mx = __gcd(a, c);
        __int128 my = __gcd(b, d);
        if (mx == 0) mx = INF;
        if (my == 0) my = INF;

        set<T> s;
        int n;
        cin >> n;
        for (int i = 0; i < n; i++) {
            long long x, y;
            cin >> x >> y;
            s.emplace(b * x - a * y, x % mx, y % my);
        }
        cout << s.size() << "\n";
        return 0;
    }

    if (m < 0) {
        m = -m;
        a = (m - a % m) % m;
        b = (m - b % m) % m;
        c = (m - c % m) % m;
        d = (m - d % m) % m;
    }

    set<P> s;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        long long xxx, yyy;
        cin >> xxx >> yyy;
        __int128 x = xxx, y = yyy;
        x %= m;
        y %= m;
        ll xx = (d * x % m + m - c * y % m) % m;
        ll yy = (a * y % m + m - b * x % m) % m;
        P tar(xx, yy);
        s.insert(tar);
    }

    cout << s.size() << "\n";
    return 0;
}
0