結果

問題 No.245 貫け!
ユーザー roiti46roiti46
提出日時 2015-07-17 23:19:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 52,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 18:12:12
合計ジャッジ時間 1,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

int xy[101][4];

bool cross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
    int tc=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
    int td=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
    return tc * td <= 0;
}

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> xy[i][0] >> xy[i][1] >> xy[i][2] >> xy[i][3];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x1 = xy[i][0], y1 = xy[i][1];
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            int x2 = xy[j][2], y2 = xy[j][3];
            int tmp = 0;
            for (int k = 0; k < N; k++) {
                int x3 = xy[k][0], y3 = xy[k][1];
                int x4 = xy[k][2], y4 = xy[k][3];
                if (cross(x1, y1, x2, y2, x3, y3, x4, y4)) tmp++;
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}
0