結果

問題 No.517 壊れたアクセサリー
ユーザー 0w10w1
提出日時 2017-08-09 13:59:48
言語 Ruby
(3.2.2)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 11,496 KB
実行使用メモリ 15,340 KB
最終ジャッジ日時 2023-08-02 08:59:01
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,120 KB
testcase_01 AC 78 ms
15,148 KB
testcase_02 AC 77 ms
15,148 KB
testcase_03 AC 73 ms
15,240 KB
testcase_04 AC 74 ms
15,148 KB
testcase_05 AC 74 ms
15,016 KB
testcase_06 AC 76 ms
15,256 KB
testcase_07 AC 76 ms
15,152 KB
testcase_08 AC 76 ms
15,236 KB
testcase_09 AC 75 ms
15,248 KB
testcase_10 AC 76 ms
15,276 KB
testcase_11 AC 77 ms
15,268 KB
testcase_12 AC 75 ms
15,160 KB
testcase_13 AC 72 ms
15,244 KB
testcase_14 AC 77 ms
15,048 KB
testcase_15 AC 77 ms
15,144 KB
testcase_16 AC 77 ms
15,292 KB
testcase_17 AC 78 ms
15,340 KB
testcase_18 AC 76 ms
15,252 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