結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yamagh
                         | 
                    
| 提出日時 | 2015-04-29 00:39:44 | 
| 言語 | Ruby  (3.4.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 690 bytes | 
| コンパイル時間 | 172 ms | 
| コンパイル使用メモリ | 7,424 KB | 
| 実行使用メモリ | 12,416 KB | 
| 最終ジャッジ日時 | 2024-06-27 08:33:44 | 
| 合計ジャッジ時間 | 5,568 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 32 WA * 11 | 
コンパイルメッセージ
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 || 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 : :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
            
            
            
        
            
yamagh