結果

問題 No.408 五輪ピック
ユーザー 37zigen37zigen
提出日時 2016-08-05 23:29:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,022 bytes
コンパイル時間 2,771 ms
コンパイル使用メモリ 80,200 KB
実行使用メモリ 65,968 KB
最終ジャッジ日時 2024-04-24 19:14:58
合計ジャッジ時間 22,483 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
40,568 KB
testcase_01 AC 115 ms
41,852 KB
testcase_02 AC 102 ms
40,536 KB
testcase_03 AC 121 ms
42,100 KB
testcase_04 AC 108 ms
40,588 KB
testcase_05 AC 519 ms
51,144 KB
testcase_06 AC 466 ms
50,592 KB
testcase_07 AC 499 ms
51,212 KB
testcase_08 AC 486 ms
50,264 KB
testcase_09 AC 497 ms
50,296 KB
testcase_10 AC 410 ms
48,932 KB
testcase_11 AC 452 ms
50,164 KB
testcase_12 AC 574 ms
51,272 KB
testcase_13 AC 529 ms
51,276 KB
testcase_14 AC 282 ms
48,760 KB
testcase_15 AC 519 ms
50,880 KB
testcase_16 AC 568 ms
51,628 KB
testcase_17 AC 584 ms
52,024 KB
testcase_18 AC 588 ms
51,552 KB
testcase_19 AC 569 ms
51,712 KB
testcase_20 AC 319 ms
49,448 KB
testcase_21 AC 259 ms
48,036 KB
testcase_22 AC 360 ms
49,484 KB
testcase_23 AC 609 ms
51,844 KB
testcase_24 WA -
testcase_25 AC 1,607 ms
60,920 KB
testcase_26 AC 645 ms
52,044 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package No400番台;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	static void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer>[] e = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			e[i] = new ArrayList<>();
		}
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			e[a].add(b);
			e[b].add(a);
		}
		boolean[] arrived=new boolean[n];
		dfs(0,0,arrived,0,e);
		System.out.println("NO");
	}
	static void dfs(int root, int p, boolean[] arrived, int depth, ArrayList<Integer>[] e) {
		if (depth == 4) {
			for (int v : e[p]) {
				if (root == v) {
					System.out.println("YES");
					System.exit(0);
				}
			}
		} else {
			for (int v : e[p]) {
				if (!arrived[v]) {
					boolean[] d = Arrays.copyOf(arrived, arrived.length);
					d[v] = true;
					dfs(root,v,d,depth+1,e);
				}
			}
		}
	}
}
0