結果

問題 No.245 貫け!
ユーザー GrenacheGrenache
提出日時 2015-07-19 10:36:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,316 bytes
コンパイル時間 5,623 ms
コンパイル使用メモリ 75,632 KB
実行使用メモリ 58,968 KB
最終ジャッジ日時 2023-09-22 19:15:22
合計ジャッジ時間 10,249 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,312 KB
testcase_01 AC 124 ms
56,084 KB
testcase_02 AC 125 ms
56,160 KB
testcase_03 AC 124 ms
55,984 KB
testcase_04 AC 124 ms
55,796 KB
testcase_05 AC 121 ms
55,920 KB
testcase_06 AC 124 ms
56,340 KB
testcase_07 AC 121 ms
58,084 KB
testcase_08 AC 132 ms
55,808 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 231 ms
57,056 KB
testcase_16 WA -
testcase_17 AC 235 ms
57,132 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; 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[2][i], a[3][i], a[0][j], a[1][j], a[0][k], a[1][k], a[2][k], a[3][k])) {
            			tmp2++;
            		}
            		if (Geom.lineIntersect(a[2][i], a[3][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