結果
問題 | No.245 貫け! |
ユーザー |
![]() |
提出日時 | 2015-09-27 16:39:28 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,656 bytes |
コンパイル時間 | 1,408 ms |
コンパイル使用メモリ | 159,968 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 10:51:25 |
合計ジャッジ時間 | 2,428 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 9 |
ソースコード
#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; };