結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 37 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 28 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 178 ms
4,376 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-7
#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