結果

問題 No.2331 Maximum Quadrilateral
ユーザー keisuke6keisuke6
提出日時 2023-05-28 14:54:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 494 ms / 2,000 ms
コード長 1,370 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 202,304 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 10:51:52
合計ジャッジ時間 11,496 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 437 ms
4,380 KB
testcase_01 AC 261 ms
4,376 KB
testcase_02 AC 316 ms
4,376 KB
testcase_03 AC 315 ms
4,380 KB
testcase_04 AC 405 ms
4,380 KB
testcase_05 AC 435 ms
4,376 KB
testcase_06 AC 404 ms
4,380 KB
testcase_07 AC 362 ms
4,376 KB
testcase_08 AC 255 ms
4,380 KB
testcase_09 AC 237 ms
4,380 KB
testcase_10 AC 218 ms
4,376 KB
testcase_11 AC 237 ms
4,376 KB
testcase_12 AC 213 ms
4,380 KB
testcase_13 AC 231 ms
4,380 KB
testcase_14 AC 450 ms
4,376 KB
testcase_15 AC 37 ms
4,380 KB
testcase_16 AC 152 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 45 ms
4,376 KB
testcase_19 AC 14 ms
4,376 KB
testcase_20 AC 494 ms
4,380 KB
testcase_21 AC 489 ms
4,376 KB
testcase_22 AC 490 ms
4,380 KB
testcase_23 AC 485 ms
4,380 KB
testcase_24 AC 492 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
int f(int x1, int y1, int x2, int y2, int x3, int y3) {
    int area = abs((x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2)));
    return area;
}
bool ff(int x1, int y1, int x2, int y2, int x3, int y3) {
    double epsilon = 1e-9;  // 許容誤差

    // 直線ABの傾きを計算
    double slopeAB = 1.0*(y2 - y1) / (x2 - x1);

    // 直線ABの方程式を用いて、点Cのy座標を予測
    double predictedY = y1 + 1.0 * slopeAB * (x3 - x1);

    // 点Cのy座標と実際のy座標の差を比較して判定
    if (predictedY > y3) {
        return true;  // Cは直線AB上にある
    } else {
        return false; // Cは直線AB上にない
    }
}
signed main(){
  int N;
  cin>>N;
  vector<int> X(N),Y(N);
  for(int i=0;i<N;i++) cin>>X[i]>>Y[i];
  int ans = 0;
  for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
  	vector<int> A = {}, B = {};
  	for(int k=0;k<N;k++){
  		if(i == k || j == k) continue;
  		if(ff(X[i],Y[i],X[j],Y[j],X[k],Y[k])) A.push_back(f(X[i],Y[i],X[j],Y[j],X[k],Y[k]));
  		else B.push_back(f(X[i],Y[i],X[j],Y[j],X[k],Y[k]));
  	}
  	int a = 0;
  	for(int x:A) a = max(a,x);
  	int b = 0;
  	for(int y:B) b = max(b,y);
  	//cout<<i<<' '<<j<<' '<<a<<' '<<b<<endl;
  	if(a == 0 || b == 0) continue;
  	ans = max(ans,a+b);
  }
  cout<<ans<<endl;
}
0