結果
問題 | No.849 yuki国の分割統治 |
ユーザー | pekempey |
提出日時 | 2019-07-05 22:27:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 1,366 bytes |
コンパイル時間 | 1,708 ms |
コンパイル使用メモリ | 173,484 KB |
実行使用メモリ | 8,832 KB |
最終ジャッジ日時 | 2024-10-06 22:21:03 |
合計ジャッジ時間 | 3,657 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#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; }