結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 11 ms
4,384 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 11 ms
4,376 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 10 ms
4,376 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 d1 = 0; d1 < 2; d1++) {
        for (int i = 0; i < N; i++) {
            int x1 = xy[i][2 * d1], y1 = xy[i][2 * d1 + 1];
            for (int d2 = 0; d2 < 2; d2++) {
                for (int j = 0; j < N; j++) {
                    int x2 = xy[j][2 * d2], y2 = xy[j][2 * d2 + 1];
                    if (x1 == x2 && y1 == y2) continue;
                    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