結果

問題 No.2063 ±2^k operations (easy)
ユーザー shoshoshomshoshoshom
提出日時 2022-09-02 22:52:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 956 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 203,512 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 05:12:18
合計ジャッジ時間 3,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  iostream::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  string n;
  cin >> n;
  vector<pair<int, int>> P;
  for (char c: n) {
    int i = c - '0';
    if (P.empty() || P.back().first != i) {
      P.push_back({i, 1});
    } else {
      P.back().second++;
    }
  }
  bool ok = false;
  int sz = (int)P.size();
  if (sz == 1 || sz == 2) {
    if (P.front().first == 1 && P.front().second > 1) {
      ok = true;
    }
  } else if (sz == 3) {
    if (P.front().first == 1 && P.front().second == 1 && P[1].second == 1) {
      ok = true;
    }
    if (P.front().first == 1 && P.front().second == 1 && P.back().first == 1 && P.back().second == 1) {
      ok = true;
    }
  } else if (sz == 4) {
    int cnt = 0;
    for (auto [i, c]: P) {
      if (i == 1) {
        cnt += c;
      }
    }
    if (cnt == 2) {
      ok = true;
    }
  }
  cout << (ok ? "Yes" : "No") << '\n';



  return 0;
}
0