結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,568 KB
testcase_01 AC 128 ms
41,304 KB
testcase_02 AC 131 ms
41,368 KB
testcase_03 AC 130 ms
41,188 KB
testcase_04 AC 118 ms
40,120 KB
testcase_05 AC 803 ms
54,724 KB
testcase_06 AC 580 ms
53,048 KB
testcase_07 AC 752 ms
54,816 KB
testcase_08 AC 705 ms
52,452 KB
testcase_09 AC 697 ms
52,756 KB
testcase_10 AC 641 ms
52,372 KB
testcase_11 AC 608 ms
52,668 KB
testcase_12 AC 796 ms
54,896 KB
testcase_13 AC 774 ms
53,828 KB
testcase_14 AC 393 ms
50,352 KB
testcase_15 AC 816 ms
53,400 KB
testcase_16 AC 727 ms
54,472 KB
testcase_17 AC 906 ms
55,472 KB
testcase_18 AC 919 ms
55,320 KB
testcase_19 AC 869 ms
59,068 KB
testcase_20 AC 449 ms
51,172 KB
testcase_21 AC 341 ms
48,980 KB
testcase_22 AC 611 ms
53,736 KB
testcase_23 AC 902 ms
59,272 KB
testcase_24 WA -
testcase_25 AC 761 ms
55,316 KB
testcase_26 AC 909 ms
61,284 KB
testcase_27 AC 797 ms
55,032 KB
testcase_28 AC 579 ms
52,512 KB
testcase_29 AC 604 ms
52,460 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