結果
問題 | No.408 五輪ピック |
ユーザー | Grenache |
提出日時 | 2016-08-06 02:34:49 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 763 ms / 5,000 ms |
コード長 | 3,438 bytes |
コンパイル時間 | 4,006 ms |
コンパイル使用メモリ | 80,140 KB |
実行使用メモリ | 61,116 KB |
最終ジャッジ日時 | 2024-04-24 17:43:27 |
合計ジャッジ時間 | 16,712 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
37,400 KB |
testcase_01 | AC | 55 ms
37,468 KB |
testcase_02 | AC | 58 ms
37,620 KB |
testcase_03 | AC | 59 ms
37,472 KB |
testcase_04 | AC | 55 ms
37,516 KB |
testcase_05 | AC | 512 ms
56,924 KB |
testcase_06 | AC | 377 ms
53,428 KB |
testcase_07 | AC | 469 ms
53,080 KB |
testcase_08 | AC | 435 ms
52,300 KB |
testcase_09 | AC | 438 ms
51,584 KB |
testcase_10 | AC | 390 ms
51,956 KB |
testcase_11 | AC | 379 ms
51,632 KB |
testcase_12 | AC | 501 ms
56,084 KB |
testcase_13 | AC | 496 ms
56,112 KB |
testcase_14 | AC | 281 ms
49,940 KB |
testcase_15 | AC | 516 ms
57,956 KB |
testcase_16 | AC | 517 ms
56,032 KB |
testcase_17 | AC | 503 ms
56,320 KB |
testcase_18 | AC | 510 ms
54,808 KB |
testcase_19 | AC | 518 ms
56,768 KB |
testcase_20 | AC | 312 ms
51,024 KB |
testcase_21 | AC | 263 ms
49,508 KB |
testcase_22 | AC | 370 ms
51,780 KB |
testcase_23 | AC | 596 ms
61,116 KB |
testcase_24 | AC | 536 ms
60,252 KB |
testcase_25 | AC | 597 ms
60,376 KB |
testcase_26 | AC | 572 ms
56,100 KB |
testcase_27 | AC | 763 ms
56,984 KB |
testcase_28 | AC | 416 ms
52,592 KB |
testcase_29 | AC | 417 ms
53,532 KB |
testcase_30 | AC | 58 ms
37,088 KB |
testcase_31 | AC | 59 ms
37,648 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]); if (edges[a] == null) { edges[a] = new HashSet<>(); } if (edges[b] == null) { edges[b] = new HashSet<>(); } 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) { if (edges2[e2] == null) { edges2[e2] = new HashSet<>(); } 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 || edges2[i] == null) { continue; } for (int e : edges2[i]) { if (e == 0 || edges2[j] == null) { 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), 128); } 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); } } }