結果

問題 No.245 貫け!
ユーザー koba-e964koba-e964
提出日時 2015-07-23 22:18:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 908 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 62,192 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 21:50:58
合計ジャッジ時間 1,524 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 23 ms
4,376 KB
testcase_13 AC 23 ms
4,380 KB
testcase_14 AC 24 ms
4,380 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 AC 24 ms
4,380 KB
testcase_17 AC 24 ms
4,380 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 23 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <complex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef complex<double> comp;
const double EPS=1e-9;

const int N = 100;

double a[N], b[N], c[N], d[N];
comp st[N], en[N];
comp pool[2 * N];
bool cross(comp x, comp y, comp z, comp w) {
  double ex1 = (conj(w - x) * (y - x)).imag();
  double ex2 = (conj(z - x) * (y - x)).imag();
  return ex1 * ex2 < EPS; // <= 0
}

int main(void) {
  int n;
  cin >> n;
  REP(i, 0, n) {
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    pool[2 * i] = st[i] = comp(a, b);
    pool[2 * i + 1] = en[i] = comp(c, d);
  }
  int ma = 0;
  REP(i, 0, 2 * n) {
    REP(j, i + 1, 2 * n) {
      int c = 0;
      if (abs(pool[i] - pool[j]) < EPS) {
	continue;
      }
      REP(k, 0, n) {
	if (cross(pool[i], pool[j], st[k], en[k])) {
	  c++;
	}
      }
      ma = max(ma, c);
    }
  }
  cout << ma << endl;
}
0