結果

問題 No.245 貫け!
ユーザー otsnskotsnsk
提出日時 2015-10-30 16:12:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,557 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 71,728 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 05:52:09
合計ジャッジ時間 2,819 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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