結果

問題 No.2063 ±2^k operations (easy)
ユーザー _yurimoir_yurimoir
提出日時 2022-10-18 11:41:22
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 839 bytes
コンパイル時間 3,312 ms
コンパイル使用メモリ 247,956 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 06:18:21
合計ジャッジ時間 5,586 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=(int)s.size();
    vector<vector<pair<int,int>>> tank(2);
    int l=0;
    char c=s[0];
    for(int i=1;i<n;i++){
        if(s[i]!=c){
            tank[c-'0'].push_back({l,i});
            l=i;
            c=s[i];
        }
        if(i==n-1){
            tank[s[i]-'0'].push_back({n,l});
        }
    }
    if(tank[1].size()>2){
        cout<<"No"<<endl;
    }else if(tank[1].size()==2){
        for(int i=0;i<2;i++){
            if(tank[1][i].second-tank[1][i].first==1)continue;
            cout<<"No"<<endl;
            return 0;
        }
        cout<<"Yes"<<endl;
        return 0;
    }else{
        if(tank[1][0].second-tank[1][0].first==1){
            cout<<"No"<<endl;
	        return 0;
        }
        cout<<"Yes"<<endl;
    }
}
0