A - Row - 982A (新定义seat)

 

A - Row

 CodeForces - 982A 


#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str,temp;
    int n;
    cin>>n>>str;
    temp="11";
    if(str.find(temp)!=-1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    temp="000";
    if(str.find(temp)!=-1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    if((str[0]=='0'&&str[1]=='0')||(str[n-2]=='0'&&str[n-1]=='0'))
    {
        cout<<"No"<<endl;
        return 0;
    }
    if((str[0]=='1'&&str[1]=='0')||(str[n-2]=='0'&&str[n-1]=='1'))
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    temp="010";
    if(str.find(temp)!=-1)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(n==1&&str[0]=='1')
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/BePosit/article/details/81537846
Row
982