竞赛讨论区 > 为什么B题我这样写不对呢
头像
牛客585371815号
发布于 昨天 21:32 广西
+ 关注

为什么B题我这样写不对呢

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int len,cnt=0,flag=0;
        string s;
        cin>>len>>s;
        s+='0';
        for(auto& x:s)
        {
            if(x=='1')
            {
                cnt++;
            }
            else
            {
                if(cnt==1)
                {
                    cout<<"NO"<<endl;
                    flag=1;
                }
                cnt=0;
            }
        }
        if(flag==0)
        {
            cout<<"YES"<<endl;
        }
    }
    return 0;
}

全部评论

(2) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐