結果

問題 No.1400 すごろくで世界旅行
ユーザー CuriousFairy315CuriousFairy315
提出日時 2019-12-31 12:30:46
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,071 bytes
コンパイル時間 5,219 ms
コンパイル使用メモリ 77,444 KB
実行使用メモリ 41,636 KB
最終ジャッジ日時 2024-05-06 09:59:28
合計ジャッジ時間 6,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder_3785;

import java.util.BitSet;
import java.util.Scanner;

public class Main2 {
	public static void main(String[] args) {
		new Main2();
	}

	public Main2() {
		try (Scanner sc = new Scanner(System.in)) {
			int V, D;
			V = sc.nextInt();
			D = sc.nextInt();
			BitSet[] graph = new BitSet[V];
			for (int i = 0;i < V;++ i) {
				graph[i] = new BitSet(V);
				String E = sc.next();
				for (int j = 0;j < V;++ j) graph[i].set(j, E.charAt(j));
			}
			boolean ans = graph[0].cardinality() > 0;

			for (int i = 0;i < V;++ i) {
				BitSet now = (BitSet)graph[i].clone(), one = new BitSet(V), two = new BitSet(V), three = new BitSet(V);
				one.set(i);
				for (int j = 1;j < D;++ j) {
					BitSet check = (BitSet)now.clone();
					check.xor(two);
					if (check.isEmpty()) break;
					two = (BitSet)one.clone();
					for (int k = check.nextSetBit(0);k >= 0;k = check.nextSetBit(k + 1)) one.or(graph[k]);
					three = now;
					now = one;
					one = three;
				}
				ans &= now.cardinality() == V;
			}
			System.out.println(ans ? "Yes" : ":(");
		}
	}
}
0