結果

問題 No.1144 Triangles
ユーザー leaf_1415leaf_1415
提出日時 2020-07-31 22:41:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,668 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 83,816 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 01:16:05
合計ジャッジ時間 7,871 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 478 ms
4,380 KB
testcase_05 AC 479 ms
4,380 KB
testcase_06 AC 478 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 479 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 444 ms
4,380 KB
testcase_15 AC 434 ms
4,376 KB
testcase_16 AC 464 ms
4,380 KB
testcase_17 AC 466 ms
4,376 KB
testcase_18 AC 466 ms
4,380 KB
testcase_19 AC 38 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 446 ms
4,376 KB
testcase_23 AC 27 ms
4,380 KB
testcase_24 AC 438 ms
4,376 KB
testcase_25 AC 143 ms
4,376 KB
testcase_26 AC 16 ms
4,380 KB
testcase_27 AC 178 ms
4,380 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define PI 3.141592653589793238
#define eps 1e-12
#define mod 1000000007

using namespace std;
typedef pair<double, llint> P;

llint n;
llint x[2005], y[2005];
vector<P> vec;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		vec.clear();
		for(int j = 1; j <= n; j++){
			if(i == j) continue;
			vec.push_back(P(atan2(y[j]-y[i], x[j]-x[i]), j));
		}
		sort(vec.begin(), vec.end());
		
		for(int j = 0; j < n-1; j++){
			vec.push_back(vec[j]);
			vec.back().first += 2 * PI;
		}
		llint l = 0, r = 0;
		for(int j = 0; j < n-1; j++){
			double ang = vec[j].first;
			llint id = vec[j].second;
			while(vec[l+1].first <= ang+eps) l++;
			while(vec[r+1].first < ang+PI-eps) r++;
			llint tmp = (x[i]*y[id]%mod + mod - x[id]*y[i]%mod) % mod;
			tmp *= r-l, tmp %= mod;
			ans += tmp, ans %= mod;
		}
	}
	cout << ans << endl;
	
	return 0;
}
0