結果
問題 | No.408 五輪ピック |
ユーザー | suppy193 |
提出日時 | 2016-11-02 14:26:37 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 492 bytes |
コンパイル時間 | 95 ms |
コンパイル使用メモリ | 11,472 KB |
実行使用メモリ | 18,244 KB |
最終ジャッジ日時 | 2023-08-16 12:38:01 |
合計ジャッジ時間 | 6,170 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 81 ms
15,048 KB |
testcase_01 | AC | 82 ms
15,128 KB |
testcase_02 | AC | 82 ms
15,048 KB |
testcase_03 | AC | 82 ms
15,184 KB |
testcase_04 | AC | 84 ms
15,128 KB |
testcase_05 | WA | - |
testcase_06 | AC | 126 ms
16,328 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 125 ms
16,852 KB |
testcase_11 | AC | 120 ms
16,840 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 98 ms
15,628 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 106 ms
16,196 KB |
testcase_21 | AC | 97 ms
15,648 KB |
testcase_22 | AC | 122 ms
16,484 KB |
testcase_23 | AC | 174 ms
17,900 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 175 ms
18,244 KB |
testcase_27 | AC | 162 ms
16,152 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 82 ms
15,320 KB |
コンパイルメッセージ
Syntax OK
ソースコード
n, m = gets.strip.split(' ').map(&:to_i) #p n, m @matrix = [] (1..n).each do |i| @matrix[i] = [] end m.times do s, e = gets.strip.split(' ').map(&:to_i) @matrix[s] << e @matrix[e] << s end #p @matrix s = 1 path = [s] def dfs(v, path) @matrix[v].each do |next_v| if next_v == 1 && path.length == 5 puts "YES" exit end return if path.length > 5 if @matrix[v].include?(next_v) && !path.include?(next_v) dfs(next_v, path << next_v) end end end dfs(s, path) puts "NO"