Submission #1534571
Source Code Expand
import java.util.Scanner; class Point { int x; int y; public Point(int x, int y) { super(); this.x = x; this.y = y; } } class Line { Point start; Point end; public Line(Point start, Point end) { super(); this.start = start; this.end = end; } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int ax = sc.nextInt(); int ay = sc.nextInt(); int bx = sc.nextInt(); int by = sc.nextInt(); Line chopLine = new Line(new Point(ax, ay), new Point(bx, by)); int N = sc.nextInt(); Point[] points = new Point[N]; for(int i=0; i<N; i++) { int x = sc.nextInt(); int y = sc.nextInt(); points[i] = new Point(x, y); } sc.close(); Line[] lines = new Line[N]; for(int i=0; i<N; i++) { lines[i] = new Line(points[i], points[(i+1)%N]); } int crossCount = 0; for(Line line : lines) { int checkA = (line.start.x - line.end.x) * (chopLine.start.y - line.start.y) + (line.start.y - line.end.y) * (line.start.x - chopLine.start.x); int checkB = (line.start.x - line.end.x) * (chopLine.end.y - line.start.y) + (line.start.y - line.end.y) * (line.start.x - chopLine.end.x); int checkC = (chopLine.start.x - chopLine.end.x) * (line.start.y - chopLine.start.y) + (chopLine.start.y - chopLine.end.y) * (chopLine.start.x - line.start.x); int checkD = (chopLine.start.x - chopLine.end.x) * (line.end.y - chopLine.start.y) + (chopLine.start.y - chopLine.end.y) * (chopLine.start.x - line.end.x); if(checkA * checkB < 0 && checkC * checkD < 0) { crossCount++; } } System.out.println(crossCount/2 + 1); } }
Submission Info
Submission Time | |
---|---|
Task | D - 一刀両断 |
User | nasmarl |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1765 Byte |
Status | WA |
Exec Time | 113 ms |
Memory | 22612 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample_00.txt, 00_sample_01.txt, 10_rand_00.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_11.txt, 10_rand_12.txt, 10_rand_13.txt, 10_rand_14.txt, 10_rand_15.txt, 10_rand_16.txt, 10_rand_17.txt, 10_rand_18.txt, 10_rand_19.txt, 10_rand_20.txt, 10_rand_21.txt, 10_rand_22.txt, 10_rand_23.txt, 10_rand_24.txt, 10_rand_25.txt, 10_rand_26.txt, 10_rand_27.txt, 10_rand_28.txt, 10_rand_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 95 ms | 20052 KB |
00_sample_01.txt | AC | 93 ms | 18772 KB |
10_rand_00.txt | WA | 113 ms | 21844 KB |
10_rand_01.txt | WA | 109 ms | 21204 KB |
10_rand_02.txt | WA | 112 ms | 21716 KB |
10_rand_03.txt | AC | 97 ms | 21716 KB |
10_rand_04.txt | WA | 96 ms | 21844 KB |
10_rand_05.txt | WA | 102 ms | 21716 KB |
10_rand_06.txt | WA | 101 ms | 22612 KB |
10_rand_07.txt | WA | 101 ms | 19028 KB |
10_rand_08.txt | WA | 99 ms | 19540 KB |
10_rand_09.txt | WA | 102 ms | 19924 KB |
10_rand_10.txt | WA | 99 ms | 20052 KB |
10_rand_11.txt | WA | 96 ms | 20560 KB |
10_rand_12.txt | AC | 96 ms | 21972 KB |
10_rand_13.txt | WA | 103 ms | 17104 KB |
10_rand_14.txt | WA | 109 ms | 18644 KB |
10_rand_15.txt | AC | 94 ms | 20820 KB |
10_rand_16.txt | WA | 101 ms | 21332 KB |
10_rand_17.txt | AC | 96 ms | 19668 KB |
10_rand_18.txt | WA | 112 ms | 21844 KB |
10_rand_19.txt | WA | 103 ms | 21844 KB |
10_rand_20.txt | AC | 98 ms | 21712 KB |
10_rand_21.txt | WA | 111 ms | 21844 KB |
10_rand_22.txt | WA | 97 ms | 21588 KB |
10_rand_23.txt | WA | 101 ms | 19412 KB |
10_rand_24.txt | WA | 95 ms | 20948 KB |
10_rand_25.txt | WA | 104 ms | 19924 KB |
10_rand_26.txt | WA | 111 ms | 19540 KB |
10_rand_27.txt | WA | 102 ms | 21716 KB |
10_rand_28.txt | WA | 100 ms | 18772 KB |
10_rand_29.txt | AC | 97 ms | 21460 KB |