結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yamagh
                         | 
                    
| 提出日時 | 2015-04-29 00:17:11 | 
| 言語 | Ruby  (3.4.1)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 543 bytes | 
| コンパイル時間 | 61 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 12,416 KB | 
| 最終ジャッジ日時 | 2024-06-27 08:11:54 | 
| 合計ジャッジ時間 | 5,520 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 28 WA * 11 RE * 4 | 
コンパイルメッセージ
Syntax OK
ソースコード
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
  puts 'FAILURE'
  exit
end
sign = o<x ? 'o' : 'x'
idx  = bef.index(sign) 
if idx.odd?
  if n.even?
    puts 'FAILURE'
    exit
  else
    puts aft.index(sign)==idx ? 'SUCCESS' : 'FAILURE'
  end
else
  aft_idx = aft.index(sign)
  if n.even?
    puts aft_idx.even? ? 'FAILURE' : 'SUCCESS'
  else
    puts (idx==0 && aft_idx==2) || (idx==2 && aft_idx==0) ? 'SUCCESS' : 'FAILURE'
  end
end
            
            
            
        
            
yamagh