結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 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 100 ms
5,376 KB
testcase_08 AC 100 ms
6,912 KB
testcase_09 AC 102 ms
6,400 KB
testcase_10 AC 107 ms
5,376 KB
testcase_11 AC 93 ms
6,016 KB
testcase_12 AC 100 ms
5,376 KB
testcase_13 AC 107 ms
6,528 KB
testcase_14 AC 106 ms
6,016 KB
testcase_15 AC 94 ms
6,784 KB
testcase_16 AC 122 ms
8,960 KB
testcase_17 AC 98 ms
5,376 KB
testcase_18 AC 124 ms
9,088 KB
testcase_19 AC 109 ms
5,760 KB
testcase_20 AC 119 ms
7,552 KB
testcase_21 AC 90 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 116 ms
7,936 KB
testcase_24 AC 104 ms
5,632 KB
testcase_25 AC 127 ms
9,984 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 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,ys[i]%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