結果

問題 No.849 yuki国の分割統治
ユーザー finefine
提出日時 2019-07-05 23:24:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,179 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 174,076 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-16 08:09:07
合計ジャッジ時間 4,367 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 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 46 ms
5,376 KB
testcase_08 AC 60 ms
5,888 KB
testcase_09 AC 55 ms
5,376 KB
testcase_10 AC 54 ms
5,376 KB
testcase_11 AC 50 ms
5,376 KB
testcase_12 AC 47 ms
5,376 KB
testcase_13 AC 59 ms
5,376 KB
testcase_14 AC 55 ms
5,376 KB
testcase_15 AC 55 ms
5,504 KB
testcase_16 AC 82 ms
7,680 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 54 ms
5,376 KB
testcase_20 AC 73 ms
6,272 KB
testcase_21 AC 36 ms
5,376 KB
testcase_22 AC 69 ms
7,040 KB
testcase_23 AC 67 ms
6,528 KB
testcase_24 AC 49 ms
5,376 KB
testcase_25 AC 88 ms
8,960 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

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

const ll INF = 1e10;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll m = a * d - b * c;
    if (m == 0) { 
        ll mx = __gcd(a, c);
        ll 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++) {
            ll 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++) {
        ll x, y;
        cin >> x >> y;
        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