結果

問題 No.849 yuki国の分割統治
ユーザー pockynypockyny
提出日時 2019-07-06 14:36:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 98,192 KB
実行使用メモリ 11,368 KB
最終ジャッジ日時 2023-07-29 00:42:07
合計ジャッジ時間 4,573 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 93 ms
7,212 KB
testcase_09 AC 94 ms
6,588 KB
testcase_10 AC 96 ms
5,636 KB
testcase_11 AC 85 ms
6,132 KB
testcase_12 AC 90 ms
5,184 KB
testcase_13 AC 99 ms
6,560 KB
testcase_14 AC 96 ms
6,228 KB
testcase_15 AC 89 ms
6,860 KB
testcase_16 AC 119 ms
8,984 KB
testcase_17 AC 89 ms
4,984 KB
testcase_18 AC 118 ms
9,216 KB
testcase_19 AC 98 ms
5,804 KB
testcase_20 AC 110 ms
7,700 KB
testcase_21 AC 81 ms
5,060 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 125 ms
10,140 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 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);
}

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){
		ll e = gcd(a,c);
		map<ll,ll> mp;
		for(i=0;i<n;i++){
			mp[-a*x[i] + b*y[i]]++;
		}
		cout << mp.size() << endl;
	}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