結果
| 問題 | No.849 yuki国の分割統治 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-06 22:36:53 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,582 bytes |
| 記録 | |
| コンパイル時間 | 2,766 ms |
| コンパイル使用メモリ | 335,520 KB |
| 実行使用メモリ | 7,968 KB |
| 最終ジャッジ日時 | 2026-06-06 22:37:02 |
| 合計ジャッジ時間 | 5,557 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 200005;
struct P {
LL x, y;
};
P a[maxn];
bool cmp(P p, P q) {
if (p.x != q.x) {
return p.x < q.x;
}
return p.y < q.y;
}
LL LLabs(LL x) {
if (x < 0)
return -x;
else
return x;
}
int main() {
freopen("group.in", "r", stdin);
freopen("group.out", "w", stdout);
LL a1, b1, c1, d1;
cin >> a1 >> b1 >> c1 >> d1;
int n;
cin >> n;
LL det = a1 * d1 - b1 * c1;
for (int i = 1; i <= n; i++) {
LL x, y;
cin >> x >> y;
if (a1 == 0 && b1 == 0 && c1 == 0 && d1 == 0) {
a[i].x = x;
a[i].y = y;
} else if (det != 0) {
LL u = __int128(d1 * x) - __int128(c1 * y);
LL v = -__int128(b1 * x) + __int128(a1 * y);
LL m = LLabs(det);
u %= m;
v %= m;
if (u < 0) {
u += m;
}
if (v < 0) {
v += m;
}
a[i].x = u;
a[i].y = v;
} else {
LL dx = a1, dy = b1;
if (dx == 0 && dy == 0) {
dx = c1;
dy = d1;
}
LL k = __int128(dx * y) - __int128(dy * x);
a[i].x = k;
a[i].y = 0;
}
}
sort(a + 1, a + n + 1, cmp);
int ans = 0;
for (int i = 1; i <= n; i++) {
if (i == 1 || a[i].x != a[i - 1].x || a[i].y != a[i - 1].y) {
ans++;
}
}
cout << ans << endl;
return 0;
}