結果

問題 No.245 貫け!
ユーザー koyoprokoyopro
提出日時 2015-10-06 16:00:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,809 bytes
コンパイル時間 1,132 ms
コンパイル使用メモリ 147,888 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-27 07:35:22
合計ジャッジ時間 2,067 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
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 #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
struct P {
    int x, y;
    P(){};
    P(int _x, int _y): x(_x), y(_y){};

    P operator * (int t) {
        return P(t * x, t * y);
    }
    P operator + (P q) {
        return P(x + q.x, y + q.y);
    }
    P operator - (P q) {
        return P(x - q.x, y - q.y);
    }
    int dot(P q) {
        return x * q.x + y * q.y;
    }
    int det(P q) {
        return x * q.y - y * q.x;
    }
};

int N;
vector<pair<P,P> > ps;

bool is_cross(P a, P b, P c, P d) {
    P v1 = a - b;
    P v2 = c - b;
    P v3 = d - b;
    if (v1.det(v2) * v1.det(v3) > 0) return false;
//    v1 = b - a;
//    v2 = c - a;
//    v3 = d - a;
//    if (v1.det(v2) * v1.det(v3) > 0) return false;
//    v1 = c - d;
//    v2 = a - d;
//    v3 = b - d;
//    if (v1.det(v2) * v1.det(v3) > 0) return false;
//    v1 = d - d;
//    v2 = a - d;
//    v3 = b - d;
//    if (v1.det(v2) * v1.det(v3) > 0) return false;
    return true;
}

int count(P p, P q) {
    int cnt = 0;
    // 線分の存在する範囲が[-200, 200]なので、それを越える線分を作る→交差判定
    P v = p - q;
    int vx = (v.x) ? abs(1000 / v.x) : 1e5;
    int vy = (v.y) ? abs(1000 / v.y) : 1e5;
    int times = min(vx, vy);
    q = q - (v * times);
    p = p + (v * times);
    REP(i,N) {
        cnt += is_cross(p, q, ps[i].first, ps[i].second);
    }
    return cnt;
}

signed main()
{
    cin >> N;
    ps.resize(N);
    REP(i,N) {
        cin >> ps[i].first.x >> ps[i].first.y;
        cin >> ps[i].second.x >> ps[i].second.y;
    }
    int maxc = 0;
    REP(i,N) REP(j,N) {
        if (i == j) continue;
        P p = ps[i].first;
        P q = ps[j].second;
        maxc = max(maxc, count(p, q));
    }
    cout << maxc << endl;
    return 0;
}
0