結果

問題 No.245 貫け!
ユーザー tubo28tubo28
提出日時 2015-06-13 00:58:10
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 3,691 bytes
コンパイル時間 1,291 ms
コンパイル使用メモリ 153,596 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 21:09:49
合計ジャッジ時間 2,707 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

typedef long double Real;
typedef complex<Real> Point;
#define x real()
#define y imag()
#define CR const &

#define EPS (1e-10)
#define EQ(a,b) (abs(a-b) < EPS)
#define LE(a,b) (EQ(a,b) || a < b)
#define GE(a,b) (EQ(a,b) || b < a)

struct Segment {
    Point p[2];
    Segment (Point a = Point(), Point b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
struct Line {
    Point p[2];
    Line (Point a = Point(), Point b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};

Real dot(Point a, Point b){
    return a.x*b.x + a.y*b.y;
}
Real cross(Point a, Point b){
    return a.x*b.y - a.y*b.x;
}

bool comp_x(Point CR p, Point CR q){ return !EQ(p.x,q.x) ? p.x < q.x : p.y < q.y; }
bool comp_y(Point CR p, Point CR q){ return !EQ(p.y,q.y) ? p.y < q.y : p.x < q.x; }

namespace std {
    bool operator < (Point CR a, Point CR b){
        return comp_x(a,b);
    }
}

enum {
    LEFT = 1,
    RIGHT = -1,
    BACK = 2,
    FRONT = -2,
    ON = 0
};
int ccw(Point p, Point q, Point r){
    Point a = q-p, b = r-p;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(dot(a,b) < -EPS) return BACK;
    if(norm(a) < norm(b)) return FRONT;
    return ON;
}

bool iLS(Line const & l, Segment const & s){
    int a = ccw(l[0], l[1], s[0]);
    int b = ccw(l[0], l[1], s[1]);
    // neither LEFT-LEFT nor RIGHT-RIGHT
    return abs(a*b) != 1;
}

signed main(){
    int n;
    cin >> n;
    vector<Segment> ss(n);
    vector<Point> ps(n*2);
    int X,Y;
    rep(i,n){
        cin >> X >> Y;
        ss[i][0] = Point(X,Y);
        cin >> X >> Y;
        ss[i][1] = Point(X,Y);
        ps[i*2] = ss[i][0];
        ps[i*2+1] = ss[i][1];
    }
    int ans = 0;
    sort(all(ps));
    ps.erase(unique(all(ps)), ps.end());
    rep(i,ps.size())rep(j,i){
        Line l(ps[i],ps[j]);
        int cnt = 0;
        rep(i,n) cnt += iLS(l,ss[i]);
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}
0