結果
問題 | No.408 五輪ピック |
ユーザー | Grenache |
提出日時 | 2016-08-06 01:40:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 835 ms / 5,000 ms |
コード長 | 2,534 bytes |
コンパイル時間 | 3,898 ms |
コンパイル使用メモリ | 79,472 KB |
実行使用メモリ | 60,876 KB |
最終ジャッジ日時 | 2024-04-24 17:10:41 |
合計ジャッジ時間 | 17,020 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
37,596 KB |
testcase_01 | AC | 59 ms
37,572 KB |
testcase_02 | AC | 58 ms
37,224 KB |
testcase_03 | AC | 57 ms
37,604 KB |
testcase_04 | AC | 55 ms
37,644 KB |
testcase_05 | AC | 421 ms
53,284 KB |
testcase_06 | AC | 320 ms
49,712 KB |
testcase_07 | AC | 390 ms
50,556 KB |
testcase_08 | AC | 373 ms
51,752 KB |
testcase_09 | AC | 379 ms
49,820 KB |
testcase_10 | AC | 344 ms
50,248 KB |
testcase_11 | AC | 329 ms
48,868 KB |
testcase_12 | AC | 420 ms
53,704 KB |
testcase_13 | AC | 413 ms
53,236 KB |
testcase_14 | AC | 246 ms
47,788 KB |
testcase_15 | AC | 420 ms
55,076 KB |
testcase_16 | AC | 428 ms
53,540 KB |
testcase_17 | AC | 419 ms
50,912 KB |
testcase_18 | AC | 445 ms
53,796 KB |
testcase_19 | AC | 446 ms
54,140 KB |
testcase_20 | AC | 310 ms
47,756 KB |
testcase_21 | AC | 265 ms
46,940 KB |
testcase_22 | AC | 370 ms
49,540 KB |
testcase_23 | AC | 475 ms
55,092 KB |
testcase_24 | AC | 404 ms
53,208 KB |
testcase_25 | AC | 544 ms
58,944 KB |
testcase_26 | AC | 463 ms
54,964 KB |
testcase_27 | AC | 807 ms
59,808 KB |
testcase_28 | AC | 709 ms
60,508 KB |
testcase_29 | AC | 835 ms
60,876 KB |
testcase_30 | AC | 56 ms
37,608 KB |
testcase_31 | AC | 55 ms
37,320 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(); List<List<Integer>> edges = new ArrayList<>(n); for (int i = 0; i < n; i++) { edges.add(new ArrayList<>()); } 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; edges.get(a[i]).add(b[i]); edges.get(b[i]).add(a[i]); } List<List<Integer>> edges2 = new ArrayList<>(n); for (int i = 0; i < n; i++) { edges2.add(new ArrayList<>()); } for (int e : edges.get(0)) { for (int e2 : edges.get(e)) { if (e2 != 0) { edges2.get(e2).add(e); } } } for (int i = 0; i < m; i++) { if (a[i] == 0 || b[i] == 0) { continue; } for (int e : edges2.get(a[i])) { if (e == 0) { continue; } for (int e2 : edges2.get(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); } } }