結果
問題 | No.408 五輪ピック |
ユーザー | Grenache |
提出日時 | 2016-08-06 02:15:43 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 939 ms / 5,000 ms |
コード長 | 3,150 bytes |
コンパイル時間 | 3,942 ms |
コンパイル使用メモリ | 80,168 KB |
実行使用メモリ | 65,264 KB |
最終ジャッジ日時 | 2024-04-24 17:35:45 |
合計ジャッジ時間 | 16,893 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
37,540 KB |
testcase_01 | AC | 53 ms
37,504 KB |
testcase_02 | AC | 53 ms
37,604 KB |
testcase_03 | AC | 54 ms
37,532 KB |
testcase_04 | AC | 54 ms
37,096 KB |
testcase_05 | AC | 481 ms
57,652 KB |
testcase_06 | AC | 358 ms
54,716 KB |
testcase_07 | AC | 419 ms
52,784 KB |
testcase_08 | AC | 390 ms
51,064 KB |
testcase_09 | AC | 393 ms
50,832 KB |
testcase_10 | AC | 386 ms
53,592 KB |
testcase_11 | AC | 341 ms
51,512 KB |
testcase_12 | AC | 467 ms
56,464 KB |
testcase_13 | AC | 446 ms
55,444 KB |
testcase_14 | AC | 253 ms
48,892 KB |
testcase_15 | AC | 475 ms
58,496 KB |
testcase_16 | AC | 470 ms
56,976 KB |
testcase_17 | AC | 479 ms
56,616 KB |
testcase_18 | AC | 483 ms
54,288 KB |
testcase_19 | AC | 485 ms
56,784 KB |
testcase_20 | AC | 296 ms
49,984 KB |
testcase_21 | AC | 253 ms
47,936 KB |
testcase_22 | AC | 375 ms
54,500 KB |
testcase_23 | AC | 552 ms
62,608 KB |
testcase_24 | AC | 486 ms
61,160 KB |
testcase_25 | AC | 630 ms
62,852 KB |
testcase_26 | AC | 567 ms
60,812 KB |
testcase_27 | AC | 939 ms
65,264 KB |
testcase_28 | AC | 376 ms
51,704 KB |
testcase_29 | AC | 384 ms
51,896 KB |
testcase_30 | AC | 54 ms
37,064 KB |
testcase_31 | AC | 53 ms
37,428 KB |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder408_1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int m = sc.nextInt(); @SuppressWarnings("unchecked") Set<Integer> edges[] = new Set[n]; for (int i = 0; i < n; i++) { edges[i] = new HashSet<>(); } // int[] a = new int[m]; // int[] b = new int[m]; for (int i = 0; i < m; i++) { // a[i] = sc.nextInt() - 1; // b[i] = sc.nextInt() - 1; int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; // edges[a[i]].add(b[i]); // edges[b[i]].add(a[i]); edges[a].add(b); edges[b].add(a); } Set<Integer>[] edges2 = new Set[n]; for (int i = 1; i < n; i++) { edges2[i] = new HashSet<>(); } for (int e : edges[0]) { for (int e2 : edges[e]) { if (e2 != 0) { edges2[e2].add(e); } } } // for (int i = 0; i < m; i++) { for (int i = 1; i < n; i++) { for (int j : edges[i]) { if (j == 0) { continue; } for (int e : edges2[i]) { if (e == 0) { continue; } for (int e2 : edges2[j]) { if (e2 == 0) { continue; } if (e != e2 && e != j && e2 != i) { pr.println("YES"); pr.close(); sc.close(); return; } } } /* if (a[i] == 0 || b[i] == 0) { continue; } for (int e : edges2[a[i]]) { if (e == 0) { continue; } for (int e2 : edges2[b[i]]) { if (e2 == 0) { continue; } if (e != e2 && e != b[i] && e2 != a[i]) { pr.println("YES"); pr.close(); sc.close(); return; } } */ } } pr.println("NO"); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { // it = Arrays.asList(br.readLine().split(" ")).iterator(); it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }