結果
問題 | No.2063 ±2^k operations (easy) |
ユーザー |
|
提出日時 | 2022-09-02 22:52:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 956 bytes |
コンパイル時間 | 1,732 ms |
コンパイル使用メモリ | 196,560 KB |
最終ジャッジ日時 | 2025-02-07 01:41:19 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#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; }