結果

問題 No.245 貫け!
ユーザー otsnsk
提出日時 2015-10-30 16:12:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,557 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 72,432 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 05:06:48
合計ジャッジ時間 1,510 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define ALL(c) begin(c), end(c)
#define sortuniq(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()),v.end())
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;

struct Point {
    int x, y;
};

int cross(int a, int b, int c, int d) {
    return a * d - b * c;
}

bool crossing(Point &a, Point &b, Point &c, Point&d) {
    return cross(b.x-a.x, b.y-a.y, c.x-a.x, c.y-a.y) *
           cross(b.x-a.x, b.y-a.y, d.x-a.x, d.y-a.y)
           <= 0;
}

Point p[105][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    FOR(i, N) {
        cin >> p[i][0].x >> p[i][0].y >> p[i][1].x >> p[i][1].y;
    }

    if (N < 3) {
        cout << N << endl;
        return 0;
    }

    int max_count = 0;
    FOR(i, N) FOR(ii, 2) {
        Point &a = p[i][ii];
        FORR(j, i+1, N) FOR(jj, 2) {
            Point &b = p[j][jj];
            int cnt = 2;
            FOR(k, N) {
                if (k==i || k==j) continue;
                cnt += (int)crossing(a, b, p[k][0], p[k][1]);
            }
            // dump(cnt);
            max_count = max(max_count, cnt);
        }
    }

    cout << max_count << endl;
    
    return 0;
}
0