結果

問題 No.197 手品
ユーザー knkknk
提出日時 2017-09-18 14:39:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,082 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 71,136 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 21:22:24
合計ジャッジ時間 2,144 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 WA -
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 WA -
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:30:57: 警告: ‘idx_a’ may be used uninitialized [-Wmaybe-uninitialized]
   30 |     std::cout << (idx_b != idx_a ? "SUCCESS" : "FAILURE") << std::endl;
      |                                                         ^
main.cpp:24:14: 備考: ‘idx_a’ はここで定義されています
   24 |   int idx_b, idx_a;
      |              ^~~~~
main.cpp:30:57: 警告: ‘idx_b’ may be used uninitialized [-Wmaybe-uninitialized]
   30 |     std::cout << (idx_b != idx_a ? "SUCCESS" : "FAILURE") << std::endl;
      |                                                         ^
main.cpp:24:7: 備考: ‘idx_b’ はここで定義されています
   24 |   int idx_b, idx_a;
      |       ^~~~~

ソースコード

diff #

#include <iostream>
#include <iomanip>

typedef long long ll;

int main(void)
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(8);
  std::string s_bef;
  ll n;
  std::string s_aft;
  std::cin >> s_bef >> n >> s_aft;
  int cnt_b = 0, cnt_a = 0;
  for (int i = 0; i < 3; ++i) {
    if (s_bef[i]=='o') cnt_b++;
    if (s_aft[i]=='o') cnt_a++;
  }
  if (cnt_b != cnt_a) {std::cout << "SUCCESS" << std::endl; return 0;}
  if ((s_bef=="ooo" && s_aft=="ooo") || (s_bef=="xxx" && s_aft=="xxx")) {
    std::cout << "FAILURE" << std::endl; return 0;
  }
  int idx_b, idx_a;
  for (int i = 0; i < 3; ++i) {
    if (s_bef[i] == (cnt_b==1 ? 'o' : 'x')) idx_b = i;
    if (s_aft[i] == (cnt_b==1 ? 'o' : 'x')) idx_a = i;
  }
  if (n==0) {
    std::cout << (idx_b != idx_a ? "SUCCESS" : "FAILURE") << std::endl;
    return 0;
  }
  if (n==1) {
    std::cout << ((idx_b==1 && abs(idx_b-idx_a)!=1) ? "SUCCESS" : "FAILURE") << std::endl;
    return 0;
  }
  std::cout << (abs(idx_b-idx_a) > n ? "SUCCESS" : "FAILURE") << std::endl;
  return 0;
}
0