結果

問題 No.849 yuki国の分割統治
ユーザー treeonetreeone
提出日時 2019-07-05 23:02:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,922 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 208,208 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-16 07:59:55
合計ジャッジ時間 5,531 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 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 WA -
testcase_08 AC 96 ms
6,940 KB
testcase_09 AC 98 ms
6,940 KB
testcase_10 AC 95 ms
6,940 KB
testcase_11 AC 84 ms
6,940 KB
testcase_12 AC 85 ms
6,944 KB
testcase_13 AC 107 ms
6,944 KB
testcase_14 AC 91 ms
6,944 KB
testcase_15 AC 81 ms
6,940 KB
testcase_16 AC 172 ms
8,576 KB
testcase_17 AC 131 ms
6,940 KB
testcase_18 AC 177 ms
8,704 KB
testcase_19 AC 134 ms
6,940 KB
testcase_20 AC 179 ms
6,940 KB
testcase_21 AC 38 ms
6,940 KB
testcase_22 AC 84 ms
6,940 KB
testcase_23 AC 77 ms
6,940 KB
testcase_24 AC 76 ms
6,944 KB
testcase_25 AC 152 ms
9,984 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
const int mod = 1000000007;
const int INF = 1e18;

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int n;
    cin >> n;
    if(a * d - b * c == 0){
        if(a != 0){
            set<P> st;
            rep(i, 0, n){
                int x, y;
                cin >> x >> y;
                P v;
                v.first = a * y - b * x;
                v.second = a;
                int G = gcd(abs(v.first), abs(v.second));
                v.first /= G;
                v.second /= G;
                st.insert(v);
            }
            cout << st.size() << endl;
        }else{
            set<P> st;
            int G = gcd(c, d);
            rep(i, 0, n){
                int x, y;
                cin >> x >> y;
                st.insert({x, (y % G + G) % G});
            }
            cout << st.size() << endl;
        }
        return 0;
    }
    set<PP> st;
    rep(i, 0, n){
        int x, y;
        cin >> x >> y;
        P u, v;
        u.second = v.second = a * d - b * c;
        u.first = d * x - c * y;
        v.first = a * y - b * x;
        if(u.second < 0){
            u.first *= -1;
            u.second *= -1;
            v.first *= -1;
            v.second *= -1;
        }
        int G = gcd(abs(u.first), abs(u.second));
        u.first /= G;
        u.second /= G;
        u.first = (u.first % u.second + u.second) % u.second;
        G = gcd(abs(v.first), abs(v.second));
        v.first /= G;
        v.second /= G;
        v.first = (v.first % v.second + v.second) % v.second;
        st.insert({u, v});
    }
    cout << st.size() << endl;
}
0