結果
問題 | No.2355 Unhappy Back Dance |
ユーザー | tenten |
提出日時 | 2023-07-05 12:30:04 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,747 ms / 6,000 ms |
コード長 | 3,103 bytes |
コンパイル時間 | 3,060 ms |
コンパイル使用メモリ | 85,380 KB |
実行使用メモリ | 46,048 KB |
最終ジャッジ日時 | 2024-07-19 06:43:48 |
合計ジャッジ時間 | 27,163 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
36,900 KB |
testcase_01 | AC | 54 ms
37,236 KB |
testcase_02 | AC | 54 ms
37,280 KB |
testcase_03 | AC | 52 ms
37,064 KB |
testcase_04 | AC | 53 ms
37,120 KB |
testcase_05 | AC | 52 ms
37,140 KB |
testcase_06 | AC | 93 ms
38,556 KB |
testcase_07 | AC | 93 ms
38,988 KB |
testcase_08 | AC | 95 ms
39,024 KB |
testcase_09 | AC | 125 ms
40,012 KB |
testcase_10 | AC | 416 ms
45,420 KB |
testcase_11 | AC | 300 ms
44,972 KB |
testcase_12 | AC | 102 ms
39,308 KB |
testcase_13 | AC | 102 ms
38,816 KB |
testcase_14 | AC | 416 ms
46,048 KB |
testcase_15 | AC | 52 ms
36,628 KB |
testcase_16 | AC | 1,715 ms
44,560 KB |
testcase_17 | AC | 1,747 ms
44,424 KB |
testcase_18 | AC | 1,729 ms
44,264 KB |
testcase_19 | AC | 1,742 ms
44,724 KB |
testcase_20 | AC | 1,713 ms
44,412 KB |
testcase_21 | AC | 826 ms
44,112 KB |
testcase_22 | AC | 271 ms
43,924 KB |
testcase_23 | AC | 282 ms
43,840 KB |
testcase_24 | AC | 1,672 ms
44,944 KB |
testcase_25 | AC | 933 ms
44,364 KB |
testcase_26 | AC | 936 ms
44,352 KB |
testcase_27 | AC | 827 ms
44,204 KB |
testcase_28 | AC | 122 ms
39,828 KB |
testcase_29 | AC | 159 ms
42,760 KB |
testcase_30 | AC | 1,485 ms
44,496 KB |
testcase_31 | AC | 1,155 ms
44,520 KB |
testcase_32 | AC | 240 ms
43,796 KB |
testcase_33 | AC | 737 ms
44,152 KB |
testcase_34 | AC | 92 ms
38,836 KB |
testcase_35 | AC | 124 ms
40,316 KB |
testcase_36 | AC | 832 ms
44,228 KB |
testcase_37 | AC | 516 ms
43,708 KB |
testcase_38 | AC | 608 ms
43,948 KB |
testcase_39 | AC | 500 ms
44,076 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); Point[] points = new Point[n]; for (int i = 0; i < n; i++) { points[i] = new Point(sc.nextLong(), sc.nextLong()); } int ans = 0; for (int i = 0; i < n; i++) { HashSet<Vect> vects = new HashSet<>(); for (int j = 0; j < n; j++) { if (i == j) { continue; } Vect x = points[i].getVect(points[j]); if (vects.contains(x)) { ans++; break; } vects.add(x); } } System.out.println(ans); } static class Point { long x; long y; public Point(long x, long y) { this.x = x; this.y = y; } public Vect getVect(Point p) { return new Vect(x - p.x, y - p.y); } } static class Vect { long x; long y; public Vect(long x, long y) { this.x = x; this.y = y; init(); } private void init() { long gcd = getGCD(Math.abs(x), Math.abs(y)); x /= gcd; y /= gcd; } private long getGCD(long x, long y) { if (y == 0) { return x; } else { return getGCD(y, x % y); } } public int hashCode() { return (int)(x + y); } public boolean equals(Object o) { Vect v = (Vect)o; return x == v.x && y == v.y; } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }