結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,140 KB
testcase_01 AC 77 ms
15,320 KB
testcase_02 AC 78 ms
15,264 KB
testcase_03 AC 78 ms
15,188 KB
testcase_04 AC 78 ms
15,272 KB
testcase_05 AC 77 ms
15,160 KB
testcase_06 AC 78 ms
15,324 KB
testcase_07 AC 78 ms
15,236 KB
testcase_08 AC 78 ms
15,144 KB
testcase_09 AC 77 ms
15,048 KB
testcase_10 AC 77 ms
15,104 KB
testcase_11 AC 77 ms
15,160 KB
testcase_12 AC 76 ms
15,008 KB
testcase_13 AC 77 ms
15,008 KB
testcase_14 WA -
testcase_15 AC 77 ms
15,228 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 77 ms
15,232 KB
testcase_24 AC 76 ms
15,136 KB
testcase_25 AC 77 ms
15,112 KB
testcase_26 AC 78 ms
15,120 KB
testcase_27 AC 77 ms
15,296 KB
testcase_28 AC 77 ms
15,192 KB
testcase_29 AC 77 ms
15,196 KB
testcase_30 AC 77 ms
15,296 KB
testcase_31 AC 77 ms
15,088 KB
testcase_32 AC 76 ms
15,156 KB
testcase_33 AC 77 ms
15,308 KB
testcase_34 AC 77 ms
15,008 KB
testcase_35 AC 77 ms
15,012 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 78 ms
15,208 KB
testcase_39 AC 78 ms
15,160 KB
testcase_40 AC 78 ms
15,184 KB
testcase_41 AC 78 ms
15,148 KB
testcase_42 AC 77 ms
15,140 KB
testcase_43 AC 77 ms
15,268 KB
testcase_44 WA -
testcase_45 AC 79 ms
15,012 KB
testcase_46 AC 77 ms
15,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

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' : 'FAILURE'
  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' : 'FAILURE'
  end
end
0