結果

問題 No.632 穴埋め門松列
ユーザー kyo1kyo1
提出日時 2020-04-24 20:38:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 713 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 167,484 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 02:42:34
合計ジャッジ時間 2,165 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<char> S(3);
  for (int i = 0; i < 3; i++) {
    cin >> S[i];
  }
  auto f = [](vector<char> S, int x) {
    vector<int> T(3);
    for (int i = 0; i < 3; i++) {
      if (S[i] == '?') {
        T[i] = x;
      } else {
        T[i] = S[i] - '0';
      }
    }
    return T[0] != T[1] && T[1] != T[2] && T[0] != T[2] &&
           (*max_element(T.begin(), T.end()) == T[1] ||
            *min_element(T.begin(), T.end()) == T[1]);
  };
  if (f(S, 1) && f(S, 4)) {
    cout << 14 << '\n';
  } else if (f(S, 1)) {
    cout << 1 << '\n';
  } else if (f(S, 4)) {
    cout << 4 << '\n';
  }
  return 0;
}
0