結果

問題 No.245 貫け!
ユーザー nCk_cvnCk_cv
提出日時 2015-07-17 22:58:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,841 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 74,908 KB
実行使用メモリ 66,328 KB
最終ジャッジ日時 2023-09-22 18:03:52
合計ジャッジ時間 9,205 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,156 KB
testcase_01 AC 125 ms
55,732 KB
testcase_02 AC 126 ms
56,124 KB
testcase_03 AC 123 ms
55,992 KB
testcase_04 AC 123 ms
56,176 KB
testcase_05 AC 126 ms
55,872 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 142 ms
55,900 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 532 ms
64,560 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		int max = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i == j)continue;
				
				int ax = a[i];
				int bx = b[i];
				
				int cx = c[j];
				int dx = d[j];
				
				Line2D xL = new Line2D.Double(ax,bx,cx,dx);	
				Line2D xLB = new Line2D.Double(cx,dx,ax,bx);	
				int ay = a[j];
				int by = b[j];
				
				int cy = c[i];
				int dy = d[i];
				
				Line2D yL = new Line2D.Double(ay,by,cy,dy);
				Line2D yLB = new Line2D.Double(cy,dy,ay,by);
				
				int xSumA = 0;
				int ySumA = 0;
				
				int xSumB = 0;
				int ySumB = 0;
				
				int xSumAB = 0;
				int ySumAB = 0;
				
				int xSumBB = 0;
				int ySumBB = 0;
				
				int xSumA2 = 0;
				int ySumA2 = 0;
				
				int xSumB2 = 0;
				int ySumB2 = 0;
				
				int xSumAB2 = 0;
				int ySumAB2 = 0;
				
				int xSumBB2 = 0;
				int ySumBB2 = 0;
				

				for(int k = 0; k < n; k++) {
					if(k == i || k == j) continue;
					Line2D target = new Line2D.Double(a[k],b[k],c[k],d[k]);
					Line2D target2 = new Line2D.Double(c[k],d[k],a[k],b[k]);
					if(target.intersectsLine(xL)) xSumA++;
					if(target.intersectsLine(yL)) ySumA++;
					if(xL.intersectsLine(target)) xSumB++;
					if(yL.intersectsLine(target)) ySumB++;
					if(target.intersectsLine(xLB)) xSumAB++;
					if(target.intersectsLine(yLB)) ySumAB++;
					if(xLB.intersectsLine(target)) xSumBB++;
					if(yLB.intersectsLine(target)) ySumBB++;
					
					if(target2.intersectsLine(xL)) xSumA2++;
					if(target2.intersectsLine(yL)) ySumA2++;
					if(xL.intersectsLine(target2)) xSumB2++;
					if(yL.intersectsLine(target2)) ySumB2++;
					if(target2.intersectsLine(xLB)) xSumAB2++;
					if(target2.intersectsLine(yLB)) ySumAB2++;
					if(xLB.intersectsLine(target2)) xSumBB2++;
					if(yLB.intersectsLine(target2)) ySumBB2++;
				}
				
				max = Math.max(xSumA+2, max);
				max = Math.max(ySumA+2, max);
				max = Math.max(xSumB+2, max);
				max = Math.max(ySumB+2, max);
				max = Math.max(xSumAB+2, max);
				max = Math.max(ySumAB+2, max);
				max = Math.max(xSumBB+2, max);
				max = Math.max(ySumBB+2, max);
				max = Math.max(xSumA2+2, max);
				max = Math.max(ySumA2+2, max);
				max = Math.max(xSumB2+2, max);
				max = Math.max(ySumB2+2, max);
				max = Math.max(xSumAB2+2, max);
				max = Math.max(ySumAB2+2, max);
				max = Math.max(xSumBB2+2, max);
				max = Math.max(ySumBB2+2, max);
				
			}
		}
		
		System.out.println(max);
		
		
		
		
	} 	
	
	
}
0