結果

問題 No.849 yuki国の分割統治
ユーザー pockynypockyny
提出日時 2019-07-06 15:24:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 92,904 KB
実行使用メモリ 10,196 KB
最終ジャッジ日時 2023-07-29 00:43:09
合計ジャッジ時間 4,418 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 90 ms
5,268 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 112 ms
8,620 KB
testcase_23 AC 109 ms
7,988 KB
testcase_24 AC 94 ms
5,704 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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{
		map<pair<ll,ll>,ll> mp;
		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