結果

問題 No.849 yuki国の分割統治
ユーザー beetbeet
提出日時 2019-07-07 17:19:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 872 bytes
コンパイル時間 2,452 ms
コンパイル使用メモリ 201,980 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-16 09:04:27
合計ジャッジ時間 5,889 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 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 WA -
testcase_08 AC 100 ms
6,944 KB
testcase_09 AC 102 ms
6,944 KB
testcase_10 AC 105 ms
6,940 KB
testcase_11 AC 92 ms
6,944 KB
testcase_12 AC 100 ms
6,944 KB
testcase_13 AC 107 ms
6,940 KB
testcase_14 AC 105 ms
6,944 KB
testcase_15 AC 94 ms
6,940 KB
testcase_16 AC 125 ms
8,704 KB
testcase_17 AC 98 ms
6,944 KB
testcase_18 AC 122 ms
8,960 KB
testcase_19 AC 107 ms
6,940 KB
testcase_20 AC 117 ms
7,680 KB
testcase_21 AC 91 ms
6,940 KB
testcase_22 AC 118 ms
8,448 KB
testcase_23 AC 117 ms
7,808 KB
testcase_24 AC 104 ms
6,940 KB
testcase_25 AC 131 ms
9,984 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b,c,d;
  cin>>a>>b>>c>>d;
  Int n;
  cin>>n;
  vector<Int> xs(n),ys(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i];

  if(a*d-b*c==0){
    Int dx=__gcd(a,c);
    Int dy=__gcd(b,d);
    if(dx==0) dx=2e9;
    if(dy==0) dy=2e9;

    using P = pair<Int, Int>;
    set<P> sp;
    for(Int i=0;i<n;i++)
      sp.emplace(xs[i]%dx,(xs[i]+ys[i])%(dx+dy));

    cout<<sp.size()<<endl;
    return 0;
  }

  Int m=abs(a*d-b*c);
  using P = pair<Int, Int>;
  set<P> sp;
  for(Int i=0;i<n;i++)
    sp.emplace(((+d*xs[i]-c*ys[i])%m+m)%m,
               ((-b*xs[i]+a*ys[i])%m+m)%m);

  cout<<sp.size()<<endl;
  return 0;
}
0