結果

問題 No.849 yuki国の分割統治
ユーザー pekempeypekempey
提出日時 2019-07-05 22:27:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,366 bytes
コンパイル時間 1,760 ms
コンパイル使用メモリ 168,868 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-04-16 07:43:19
合計ジャッジ時間 4,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 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 44 ms
5,376 KB
testcase_08 AC 55 ms
6,016 KB
testcase_09 AC 51 ms
5,376 KB
testcase_10 AC 47 ms
5,376 KB
testcase_11 AC 46 ms
5,376 KB
testcase_12 AC 44 ms
5,376 KB
testcase_13 AC 54 ms
5,376 KB
testcase_14 AC 50 ms
5,376 KB
testcase_15 AC 49 ms
5,632 KB
testcase_16 AC 71 ms
7,424 KB
testcase_17 AC 40 ms
5,376 KB
testcase_18 AC 70 ms
7,808 KB
testcase_19 AC 49 ms
5,376 KB
testcase_20 AC 63 ms
6,400 KB
testcase_21 AC 31 ms
5,376 KB
testcase_22 AC 63 ms
7,040 KB
testcase_23 AC 64 ms
6,400 KB
testcase_24 AC 47 ms
5,376 KB
testcase_25 AC 75 ms
8,832 KB
testcase_26 AC 1 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>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  /*
  static bool can[200][200];
  queue<int> qy;
  queue<int> qx;
  qy.push(100);
  qx.push(100);
  auto ins = [&](int x, int y) {
    if (x < 0 || y < 0 || x >= 200 || y >= 200) return;
    if (!can[x][y]) {
      can[x][y] = true;
      qx.push(x);
      qy.push(y);
    }
  };
  while (!qx.empty()) {
    int x = qx.front(); qx.pop();
    int y = qy.front(); qy.pop();
    ins(x + a, y + b);
    ins(x - a, y - b);
    ins(x + c, y + d);
    ins(x - c, y - d);
  }
  rep(i, 100) {
    rep(j, 100) {
      cout << can[i][j];
    }
    cout << endl;
  }
  */
  set<pair<ll, ll>> st;
  int n;
  cin >> n;
  ll det = abs(a * d - b * c);
  ll gx = __gcd(a, c);
  ll gy = __gcd(b, d);
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    if (det != 0) {
      ll nx = d * x - c * y;
      ll ny = -b * x + a * y;
      nx %= det;
      ny %= det;
      if (nx < 0) nx += det;
      if (ny < 0) ny += det;
      st.emplace(nx, ny);
    } else if (gx != 0) {
      st.emplace(-b*x + a*y, x % gx);
    } else {
      st.emplace(-b*x + a*y, y % gy);
    }
  }
  cout << st.size() << endl;
}
0