結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-05-20 10:36:01 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,205 bytes | 
| コンパイル時間 | 508 ms | 
| コンパイル使用メモリ | 66,700 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-28 14:33:54 | 
| 合計ジャッジ時間 | 1,933 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 42 WA * 1 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:40:5: warning: 'result' may be used uninitialized [-Wmaybe-uninitialized]
   40 |     if(result)  cout << "SUCCESS" << endl;
      |     ^~
main.cpp:7:10: note: 'result' was declared here
    7 |     bool result;
      |          ^~~~~~
            
            ソースコード
#include<iostream>
using namespace std;
int main(){
    string before, after;
    int n;
    bool result;
    cin >> before >> n >> after;
    int bo = 0, ao = 0, ax = 0, bx = 0;
    for(int i = 0; i < 3; i++){
        if(before[i] == 'o')    bo++;
        else                    bx++;
        if(after[i] == 'o')     ao++;
        else                    bx++;
    }
    if(bo != ao){
        result = true;
    }else{
        if(bo != 2){
            for(int i = 0; i < 3; i++){
                if(before[i] == 'o')    before[i] = 'x';
                else                    before[i] = 'o';
                if(after[i] == 'o')     after[i] = 'x';
                else                    after[i] = 'o';
            }
        }
        if(n == 0){
            result = (before != after);
        }else if(n == 1){
            result = (before[1] == after[1] && before[1] == 'x') ||
                        (before[0] == after[2] && before[0] == 'x') ||
                            (before[2] == after[0] && before[2] == 'x');
        }else if(n >= 2){
            result = false;
        }
    }
    if(result)  cout << "SUCCESS" << endl;
    else        cout << "FAILURE" << endl;
    return 0;
}