結果

問題 No.245 貫け!
ユーザー alpha_virginisalpha_virginis
提出日時 2015-09-27 16:39:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,656 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 147,004 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-26 16:46:45
合計ジャッジ時間 3,042 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <unistd.h>

#include <bits/stdc++.h>

const int INF = (1 << 29);
typedef std::uint_fast32_t u32;
typedef std::int_fast32_t s32;
typedef std::uint_fast64_t u64;

template<typename T>
inline std::istream& operator >> (std::istream& is, std::complex<T>& C) {
  T R, I;
  std::cin >> R >> I;
  C = std::complex<T>(R, I);
  return is;
}

template<typename T>
class n32 {
  double EPS_ = 0.000001;
public:
  int operator () (std::complex<T> L1, std::complex<T> L2, std::complex<T> P) {
    if( ((P - L1) * conj(L2 - L1)).imag() > EPS_ ) return 1;
    else if( ((P - L1) * conj(L2 - L1)).imag() < -EPS_ ) return -1;
    return 0;
  }
};

n32<double> up_and_down_decision;

template<typename T>
class n33 {
  n32<T> up_and_down_decision_;
public:
  bool operator () (std::complex<T> P1, std::complex<T> P2, std::complex<T> P3, std::complex<T> P4) {
    return ( up_and_down_decision_(P1, P2, P3) * up_and_down_decision_(P1, P2, P4) <= 0
             and
             up_and_down_decision_(P3, P4, P1) * up_and_down_decision_(P3, P4, P2) <= 0 );
  }
};

n33<double> is_intersected;

int main() {

  int n;
  std::complex<double> P1[128], P2[128];
  std::complex<double> Pall[256];

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> P1[i] >> P2[i];
    Pall[i * 2]     = P1[i];
    Pall[i * 2 + 1] = P2[i];
  }

  int res = 0;
  for(int i = 0; i < 2 * n; ++i) {
    for(int j = i + 1; j < 2 * n; ++j) {
      int count = 0;
      for(int k = 0; k < n; ++k) {
        if( is_intersected(Pall[i], Pall[j], P1[k], P2[k]) ) count += 1;
      }
      res = std::max(res, count);
    }
  }

  std::cout << res << std::endl;      
  
  return 0;
};

0