結果

問題 No.197 手品
ユーザー yamaghyamagh
提出日時 2015-04-29 00:44:44
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,584 KB
実行使用メモリ 15,436 KB
最終ジャッジ日時 2023-09-09 15:47:20
合計ジャッジ時間 5,341 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,156 KB
testcase_01 AC 82 ms
15,292 KB
testcase_02 AC 79 ms
15,160 KB
testcase_03 AC 78 ms
15,160 KB
testcase_04 AC 78 ms
15,056 KB
testcase_05 WA -
testcase_06 AC 78 ms
15,196 KB
testcase_07 AC 79 ms
15,152 KB
testcase_08 AC 79 ms
15,296 KB
testcase_09 AC 77 ms
15,296 KB
testcase_10 AC 78 ms
15,288 KB
testcase_11 AC 77 ms
15,308 KB
testcase_12 AC 78 ms
15,092 KB
testcase_13 AC 78 ms
15,156 KB
testcase_14 WA -
testcase_15 AC 77 ms
15,148 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 76 ms
15,136 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 77 ms
15,244 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 76 ms
15,312 KB
testcase_31 AC 76 ms
15,052 KB
testcase_32 AC 76 ms
15,052 KB
testcase_33 WA -
testcase_34 AC 77 ms
15,140 KB
testcase_35 AC 76 ms
15,152 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 77 ms
15,272 KB
testcase_41 AC 77 ms
15,080 KB
testcase_42 AC 77 ms
15,304 KB
testcase_43 AC 79 ms
15,408 KB
testcase_44 WA -
testcase_45 AC 77 ms
15,140 KB
testcase_46 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

bef, n, aft = gets, gets.to_i, gets

o, x = bef.count('o'), bef.count('x')

if bef.count('o') != aft.count('o')
  puts :SUCCESS
  exit
end

if o == 3 || o == 0
  puts :FAILURE
  exit
end

if n==0 && bef!=aft
  puts :SUCCESS
  exit
end

sign = o<x ? 'o' : 'x'
idx  = bef.index(sign) 

if idx.odd?
  if n == 0
    puts bef==aft ? :FAILURE : :SUCCESS
  elsif n.even?
    puts :FAILURE
  else
    puts aft.index(sign)==idx ? :SUCCESS : :SUCCESS
  end
else
  aft_idx = aft.index(sign)
  if n == 0
    puts bef==aft ? :FAILURE : :SUCCESS
  elsif n.even?
    puts aft_idx.even? ? :FAILURE : :SUCCESS
  else
    puts (idx==0 && aft_idx==2) || (idx==2 && aft_idx==0) ? :SUCCESS : :SUCCESS
  end
end
0