結果
問題 | No.245 貫け! |
ユーザー | tubo28 |
提出日時 | 2015-06-13 01:34:53 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 4,539 bytes |
コンパイル時間 | 1,701 ms |
コンパイル使用メモリ | 172,556 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 15:57:39 |
合計ジャッジ時間 | 2,218 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 3 ms
6,944 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 13 ms
6,940 KB |
testcase_12 | AC | 29 ms
6,940 KB |
testcase_13 | AC | 30 ms
6,944 KB |
testcase_14 | AC | 28 ms
6,940 KB |
testcase_15 | AC | 28 ms
6,940 KB |
testcase_16 | AC | 29 ms
6,940 KB |
testcase_17 | AC | 29 ms
6,940 KB |
testcase_18 | AC | 30 ms
6,944 KB |
testcase_19 | AC | 28 ms
6,940 KB |
ソースコード
#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(const Line &l, const Segment &s) { return cross(l[1]-l[0], s[0]-l[0])* // s[0] is left of l cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l } #define MIN_N 1 #define MAX_N 100 #define MAX_ABS_XY 100 signed main(){ int n; cin >> n; assert(MIN_N <= n && n <= MAX_N); vector<Segment> ss(n); vector<Point> ps(n*2); int X,Y; rep(i,n){ cin >> X >> Y; dump(X,Y); assert(abs(X) <= MAX_ABS_XY); assert(abs(Y) <= MAX_ABS_XY); ss[i][0] = Point(X,Y); cin >> X >> Y; assert(abs(X) <= MAX_ABS_XY); assert(abs(Y) <= MAX_ABS_XY); ss[i][1] = Point(X,Y); ps[i*2] = ss[i][0]; ps[i*2+1] = ss[i][1]; } int ans = 0; vector<Segment> anss; Line ansl; sort(all(ps)); ps.erase(unique(all(ps)), ps.end()); rep(i,ps.size())rep(j,i){ Line l(ps[i],ps[j]); vector<Segment> cs; rep(k,n){ if(iLS(l,ss[k])){ cs.pb(ss[k]); } } if(ans < (int)cs.size()){ ans = cs.size(); ansl = l; anss = cs; } } // printf("line(%d,%d,%d,%d);\n", // (int)ansl[0].x, // (int)ansl[0].y, // (int)ansl[1].x, // (int)ansl[1].y); // rep(i,anss.size()){ // printf("line(%d,%d,%d,%d);\n", // (int)anss[i][0].x, // (int)anss[i][0].y, // (int)anss[i][1].x, // (int)anss[i][1].y); // } cout << ans << endl; }