結果

問題 No.408 五輪ピック
ユーザー uafr_csuafr_cs
提出日時 2016-08-05 23:11:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 2,594 ms
コンパイル使用メモリ 78,832 KB
実行使用メモリ 61,080 KB
最終ジャッジ日時 2024-04-24 16:32:06
合計ジャッジ時間 17,545 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
41,176 KB
testcase_01 AC 110 ms
41,132 KB
testcase_02 AC 110 ms
40,840 KB
testcase_03 AC 110 ms
40,928 KB
testcase_04 AC 113 ms
41,480 KB
testcase_05 AC 619 ms
54,644 KB
testcase_06 AC 424 ms
52,780 KB
testcase_07 AC 566 ms
53,692 KB
testcase_08 AC 533 ms
52,644 KB
testcase_09 AC 478 ms
52,416 KB
testcase_10 AC 509 ms
52,164 KB
testcase_11 AC 453 ms
52,044 KB
testcase_12 AC 653 ms
54,348 KB
testcase_13 AC 636 ms
54,200 KB
testcase_14 AC 294 ms
49,756 KB
testcase_15 AC 621 ms
54,336 KB
testcase_16 AC 637 ms
54,472 KB
testcase_17 AC 634 ms
54,820 KB
testcase_18 AC 680 ms
55,040 KB
testcase_19 AC 677 ms
54,768 KB
testcase_20 AC 341 ms
51,960 KB
testcase_21 AC 290 ms
48,096 KB
testcase_22 AC 417 ms
53,576 KB
testcase_23 AC 714 ms
58,296 KB
testcase_24 WA -
testcase_25 AC 557 ms
55,224 KB
testcase_26 AC 736 ms
61,080 KB
testcase_27 AC 641 ms
54,336 KB
testcase_28 AC 478 ms
52,408 KB
testcase_29 AC 536 ms
52,684 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		ArrayList<HashSet<Integer>> adj = new ArrayList<HashSet<Integer>>();
		for(int i = 0; i < N; i++){ adj.add(new HashSet<Integer>()); }
		
		for(int i = 0; i < M; i++){
			final int A = sc.nextInt() - 1;
			final int B = sc.nextInt() - 1;
			
			adj.get(A).add(B);
			adj.get(B).add(A);
		}
		//System.out.println(adj);
		
		ArrayList<HashSet<Integer>> to_1 = new ArrayList<HashSet<Integer>>();
		for(int i = 0; i < N; i++){ to_1.add(new HashSet<Integer>()); }
		
		for(int i = 1; i < N; i++){
			for(final int j : adj.get(i)){
				if(adj.get(j).contains(0)){
					to_1.get(i).add(j);
				}
			}
		}
		
		//System.out.println(to_1);
		
		for(int fst = 1; fst < N; fst++){
			for(final int snd : adj.get(fst)){
				final HashSet<Integer> fst_to_1 = to_1.get(fst);
				final HashSet<Integer> snd_to_1 = to_1.get(snd);
				
				//System.out.println(fst_to_1 + " " + snd_to_1);
				
				if(fst_to_1.isEmpty() || snd_to_1.isEmpty()){ continue; }
				
				if(!fst_to_1.equals(snd_to_1)){
					System.out.println("YES");
					return;
				}
			}
		}
		
		System.out.println("NO");
		return;
	}

}
0