結果

問題 No.849 yuki国の分割統治
ユーザー otoshigootoshigo
提出日時 2023-12-09 19:45:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,069 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 87,612 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2023-12-09 19:45:44
合計ジャッジ時間 4,405 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 44 ms
7,040 KB
testcase_09 AC 41 ms
6,676 KB
testcase_10 AC 42 ms
6,676 KB
testcase_11 AC 39 ms
6,676 KB
testcase_12 AC 37 ms
6,676 KB
testcase_13 AC 46 ms
6,676 KB
testcase_14 AC 43 ms
6,676 KB
testcase_15 AC 42 ms
6,784 KB
testcase_16 AC 56 ms
8,960 KB
testcase_17 AC 34 ms
6,676 KB
testcase_18 AC 57 ms
9,216 KB
testcase_19 AC 42 ms
6,676 KB
testcase_20 AC 52 ms
7,680 KB
testcase_21 AC 27 ms
6,676 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 45 ms
6,676 KB
testcase_25 AC 61 ms
10,240 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<numeric>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int N;
    cin>>N;
    vector<ll>X(N),Y(N);
    for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
    if(a*d==b*c){
        set<pair<ll,ll>>se;
        for(int i=0;i<N;i++){
            ll p=b*X[i]-a*Y[i],q=X[i]%gcd(a,b);
            se.insert(make_pair(p,q));
        }
        cout<<se.size()<<"\n";
    }else{
        set<pair<ll,ll>>se;
        ll M=abs(a*d-b*c);
        for(int i=0;i<N;i++){
            ll p=(d*X[i]-c*Y[i])%M,q=(-b*X[i]+a*Y[i])%M;
            if(p<0)p+=M;
            if(q<0)q+=M;
            se.insert(make_pair(p,q));
        }
        cout<<se.size()<<"\n";
    }
}
0