結果

問題 No.517 壊れたアクセサリー
ユーザー 0w10w1
提出日時 2017-08-09 13:59:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-20 08:31:31
合計ジャッジ時間 2,665 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
12,288 KB
testcase_01 AC 97 ms
12,288 KB
testcase_02 AC 91 ms
12,160 KB
testcase_03 AC 90 ms
12,160 KB
testcase_04 AC 91 ms
12,288 KB
testcase_05 AC 95 ms
12,160 KB
testcase_06 AC 91 ms
12,160 KB
testcase_07 AC 91 ms
12,160 KB
testcase_08 AC 90 ms
12,160 KB
testcase_09 AC 91 ms
12,160 KB
testcase_10 AC 91 ms
12,160 KB
testcase_11 AC 91 ms
12,032 KB
testcase_12 AC 90 ms
12,288 KB
testcase_13 AC 91 ms
12,160 KB
testcase_14 AC 92 ms
12,288 KB
testcase_15 AC 91 ms
12,032 KB
testcase_16 AC 91 ms
12,288 KB
testcase_17 AC 92 ms
12,032 KB
testcase_18 AC 92 ms
12,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:8: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

A, B = 2.times.map do
  gets.to_i.times.map do
    gets.chomp
  end
end

pf = A.map { |a| a[0] } & B.map { |b| b[0] }
(p -1; exit) if pf.size > 1
z = pf[0]
x = A.find { |a| a[0] == z }
y = B.find { |b| b[0] == z }
until x.size == y.size
  x += A.find { |a| a[0] == y[x.size] } while x.size < y.size
  y += B.find { |b| b[0] == x[y.size] } while y.size < x.size
end
puts x
0