結果

問題 No.245 貫け!
ユーザー GrenacheGrenache
提出日時 2015-07-19 09:40:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,320 bytes
コンパイル時間 5,017 ms
コンパイル使用メモリ 78,348 KB
実行使用メモリ 57,628 KB
最終ジャッジ日時 2023-09-22 19:15:07
合計ジャッジ時間 9,725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,728 KB
testcase_01 AC 127 ms
55,588 KB
testcase_02 AC 128 ms
55,892 KB
testcase_03 AC 123 ms
55,516 KB
testcase_04 AC 124 ms
55,820 KB
testcase_05 AC 126 ms
55,752 KB
testcase_06 AC 126 ms
55,752 KB
testcase_07 WA -
testcase_08 AC 135 ms
55,764 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 233 ms
56,804 KB
testcase_16 WA -
testcase_17 AC 239 ms
57,048 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder245 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[][] a = new int[4][n];
        for (int i = 0; i < n; i++) {
        	for (int j = 0; j < 4; j++) {
        		a[j][i] = sc.nextInt();
        	}
        }

        int max = 0;
        for (int i = 0; i < n; i++) {
        	for (int j = i + 1; j < n; j ++) {
            	int tmp = 0;
            	int tmp1 = 0;
            	int tmp2 = 0;
            	int tmp3 = 0;
            	for (int k = 0; k < n; k++) {
            		if (Geom.lineIntersect(a[0][i], a[1][i], a[0][j], a[1][j], a[0][k], a[1][k], a[2][k], a[3][k])) {
            			tmp++;
            		}
            		if (Geom.lineIntersect(a[0][i], a[1][i], a[2][j], a[3][j], a[0][k], a[1][k], a[2][k], a[3][k])) {
            			tmp1++;
            		}
            		if (Geom.lineIntersect(a[1][i], a[2][i], a[0][j], a[1][j], a[0][k], a[1][k], a[2][k], a[3][k])) {
            			tmp2++;
            		}
            		if (Geom.lineIntersect(a[1][i], a[2][i], a[2][j], a[3][j], a[0][k], a[1][k], a[2][k], a[3][k])) {
            			tmp3++;
            		}
            	}
            	
            	max = Math.max(max, tmp);
            	max = Math.max(max, tmp1);
            	max = Math.max(max, tmp2);
            	max = Math.max(max, tmp3);
        	}
        }
        
        System.out.println(max);

        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Geom {
		static int dot(int xa, int ya, int xb, int yb) {
			return xa * xb + ya * yb;
		}

		static int cross(int xa, int ya, int xb, int yb) {
			return xa * yb - xb * ya;
		}
		
		static int sumofsquare(int xa, int ya) {
			return xa * xa + ya * ya;
		}

		static boolean lineIntersect(int xa, int ya, int xb, int yb, int xc, int yc, int xd, int yd) {
			int abx = xb - xa;
			int aby = yb - ya;
			int acx = xc - xa;
			int acy = yc - ya;
			int adx = xd - xa;
			int ady = yd - ya;
			int cdx = xd - xc;
			int cdy = yd - yc;
			int cax = xa - xc;
			int cay = ya - yc;
			int cbx = xb - xc;
			int cby = yb - yc;

			return ((long)cross(abx, aby, acx, acy) * cross(abx, aby, adx, ady) <= 0)
					&& ((long)cross(cdx, cdy, cax, cay) * cross(cdx, cdy, cbx, cby) <= 0);
		}
	}
}
0