結果

問題 No.849 yuki国の分割統治
ユーザー mugen_1337mugen_1337
提出日時 2020-04-07 20:46:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,721 bytes
コンパイル時間 2,638 ms
コンパイル使用メモリ 206,012 KB
実行使用メモリ 8,644 KB
最終ジャッジ日時 2023-09-22 08:37:34
合計ジャッジ時間 7,493 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 RE -
testcase_08 AC 50 ms
5,716 KB
testcase_09 AC 49 ms
4,924 KB
testcase_10 AC 46 ms
4,380 KB
testcase_11 AC 44 ms
4,908 KB
testcase_12 AC 42 ms
4,380 KB
testcase_13 AC 53 ms
5,032 KB
testcase_14 AC 47 ms
4,540 KB
testcase_15 AC 47 ms
5,532 KB
testcase_16 AC 61 ms
7,412 KB
testcase_17 AC 36 ms
4,380 KB
testcase_18 AC 65 ms
7,660 KB
testcase_19 AC 47 ms
4,464 KB
testcase_20 AC 58 ms
6,136 KB
testcase_21 AC 28 ms
4,380 KB
testcase_22 AC 59 ms
7,016 KB
testcase_23 AC 57 ms
6,496 KB
testcase_24 AC 42 ms
4,380 KB
testcase_25 AC 73 ms
8,644 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

ll A,B,C,D;

void f(pair<ll,ll> u,pair<ll,ll> v){
    if(v.first==0){
        A=u.first;B=u.second;
        D=v.second;
        if(A<0){
            A=-A;B=-B;
        }
        if(D<0) D=-D;
        return ;
    }

    if(u.first<v.first){
        f(v,u);
    }else{
        u.first-=v.first;
        u.second-=v.second;
        f(u,v);
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    ll a,b,c,d;cin>>a>>b>>c>>d;
    f(make_pair(a,b),make_pair(c,d));
    //C=0
    /* 代表点への移動
    x' = x + k*A + l*0
    y' = y + k*B + l*D
    代表点は0<=x<Aかつ0<=y<Dとなる.これは各x,yに対し唯一必ず存在
    */
    int n;cin>>n;
    set<pair<ll,ll>> st;

    rep(i,n){
        ll x,y;cin>>x>>y;
        pair<ll,ll> res;
        ll k;
        if(x>=0){
            res.first=x%A;
            k=-(x/A);
        }else{
            k=(abs(x)+A-1)/A;
            res.first=x+k*A;
        }
        res.second=y+k*B;
        if(D!=0){
            res.second=y+k*B;
            res.second%=D;
            res.second+=D;
            res.second%=D;
        }
        st.insert(res);
    }
    cout<<st.size()<<endl;
    return 0;
}
0