結果

問題 No.849 yuki国の分割統治
ユーザー pockynypockyny
提出日時 2019-07-06 15:25:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 93,672 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-16 08:33:29
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 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,944 KB
testcase_07 AC 97 ms
6,944 KB
testcase_08 AC 100 ms
7,168 KB
testcase_09 AC 103 ms
6,944 KB
testcase_10 AC 102 ms
6,944 KB
testcase_11 AC 92 ms
6,940 KB
testcase_12 AC 96 ms
6,944 KB
testcase_13 AC 105 ms
6,940 KB
testcase_14 AC 102 ms
6,944 KB
testcase_15 AC 94 ms
6,944 KB
testcase_16 AC 128 ms
9,216 KB
testcase_17 AC 95 ms
6,940 KB
testcase_18 AC 132 ms
9,472 KB
testcase_19 AC 104 ms
6,944 KB
testcase_20 AC 119 ms
7,936 KB
testcase_21 AC 89 ms
6,944 KB
testcase_22 AC 123 ms
8,576 KB
testcase_23 AC 117 ms
8,064 KB
testcase_24 AC 101 ms
6,940 KB
testcase_25 AC 141 ms
10,368 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
ll x[100010],y[100010];
ll gcd(ll a, ll b){
	if(a<b) swap(a,b);
	if(b==0) return a;
	return gcd(a%b,b);
}
map<pair<ll,ll>,ll> mp;
int main(){
	ll i,n,a,b,c,d;
	cin >> a >> b >> c >> d >> n;
	ll mod = abs(a*d - b*c);
	for(i=0;i<n;i++){
		cin >> x[i] >> y[i];
	}
	if(mod==0){
		a = gcd(a,c);
		b = gcd(b,d);
		if(a==0){
			swap(a,b);
			for(i=0;i<n;i++){
				swap(x[i],y[i]);
			}
		}
		for(i=0;i<n;i++){
			mp[{x[i]%a,a*y[i] - b*x[i]}]++;
		}
	}else{
		for(i=0;i<n;i++){
			ll u = d*x[i]%mod - c*y[i]%mod,v = -b*x[i]%mod + a*y[i]%mod;
			if(u<0) u += mod;
			if(v<0) v += mod;
			mp[{u,v}]++;
		}
	}
	cout << mp.size() << endl;
}
0