結果

問題 No.245 貫け!
ユーザー nanasilinanasili
提出日時 2015-07-28 15:34:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,492 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 87,932 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-23 04:42:24
合計ジャッジ時間 1,789 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>
#include <complex>
#define rep(i,n) for (int i=0; i < (n); i++)

using namespace std;

typedef long long ll;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積 dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積 cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 点の進行方向
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 直線と点
bool isecLP(P a1, P a2, P b) {
  return abs(ccw(a1, a2, b)) != 1;  // return EQ(cross(a2-a1, b-a1), 0); と等価
}

// 直線と直線
bool isecLL(P a1, P a2, P b1, P b2) {
  return !isecLP(a2-a1, b2-b1, 0) || isecLP(a1, b1, b2);
}

// 直線と線分
bool isecLS(P a1, P a2, P b1, P b2) {
  return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}

// 線分と線分
bool isecSS(P a1, P a2, P b1, P b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

// 線分と点
bool isecSP(P a1, P a2, P b) {
  return !ccw(a1, a2, b);
}

int main() {
  int n;
  scanf("%d", &n);
  P a[n], b[n];
  for (int i = 0; i < n; i++) {
    D x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    a[i] = P(x1, y1);
    b[i] = P(x2, y2);
  }

  int ans = 1;
  for (int i = 0; i < n; i++) {
    P sp, ep;
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      sp = a[i];
      ep = b[j];

      cnt = 0;
      for (int k = 0; k < n; k++) {
	cnt += isecLS(sp, ep, a[k], b[k]);
      }
      ans = max(ans, cnt);

    }
  }

  printf("%d\n", ans);
}
0