結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTSMasKoaTS
提出日時 2022-02-22 18:19:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,198 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 88,444 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-04-25 22:58:01
合計ジャッジ時間 3,977 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 121 ms
8,704 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 102 ms
8,192 KB
testcase_18 WA -
testcase_19 AC 97 ms
7,936 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 161 ms
8,704 KB
testcase_23 WA -
testcase_24 AC 37 ms
6,940 KB
testcase_25 WA -
testcase_26 AC 74 ms
6,944 KB
testcase_27 AC 61 ms
6,940 KB
testcase_28 AC 106 ms
8,320 KB
testcase_29 AC 50 ms
6,940 KB
testcase_30 AC 22 ms
6,944 KB
testcase_31 WA -
testcase_32 AC 66 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
const ll mod = 1000000007;


ll gcd(ll a, ll b) {
	a = abs(a);	b = abs(b);
	while (b != 0) {
		ll r = a % b;
		a = b;
		b = r;
	}
	return a;
}

ll area(V<ll>&v1, V<ll>&v2) {
	ll x1 = v1[0] % mod, y1 = v1[1] % mod;
	ll x2 = v2[0] % mod, y2 = v2[1] % mod;
	return (x1 * y2 % mod - x2 * y1 % mod) % mod;
}

bool arg_sort(const V<ll>&v1, const V<ll>&v2) {
	ll x1 = v1[0], y1 = v1[1];
	ll x2 = v2[0], y2 = v2[1];
	return (x1 * y2 > x2 * y1);
}


int main(void) {
	int n;	cin >> n;
	VV<ll> v(n, V<ll>(2));
	rep(i, 0, n) {
		ll x, y;	cin >> x >> y;
		if (y < 0) {
			x = -x;	y = -y;
		}
		v[i] = { x,y };
	}
	sort(all(v), arg_sort);

	ll	S = 0, bh = 0;
	ll lx = 0, ly = 0;
	for (auto& l : v) {
		ll x = l[0], y = l[1];
		V<ll> v1 = { lx,ly };
		V<ll> v2 = { lx + x,ly + y };
		S += area(v1, v2);
		S %= mod;
		bh += gcd(x, y);
		bh %= mod;
		lx = v2[0]; ly = v2[1];
	}

	ll ans = (S + bh + 1) % mod;
	cout << ans << endl;

	return 0;
}
0