結果
問題 | No.197 手品 |
ユーザー |
|
提出日時 | 2018-05-20 10:37:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,263 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 66,440 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 03:54:22 |
合計ジャッジ時間 | 1,674 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:42:5: warning: 'result' may be used uninitialized [-Wmaybe-uninitialized] 42 | 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 == 3 || bx == 3){ result = false; }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; }