結果
問題 |
No.1400 すごろくで世界旅行
|
ユーザー |
![]() |
提出日時 | 2019-12-31 12:30:46 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,071 bytes |
コンパイル時間 | 3,392 ms |
コンパイル使用メモリ | 78,188 KB |
実行使用メモリ | 56,296 KB |
最終ジャッジ日時 | 2024-11-28 15:50:42 |
合計ジャッジ時間 | 6,900 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | WA * 2 RE * 16 |
ソースコード
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" : ":("); } } }