日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Round #484 (Div. 2) A. Row

發布時間:2025/3/20 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #484 (Div. 2) A. Row 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Example 1 input 3 101 output YesExample 2 input 4 1011 output NoExample 3 input 5 10001 output No

  

題目大意:

題意:“最大”人數的作為定義滿足下面兩條:1.相鄰座位沒有人 2.在不違背第一條的情況下,不能在加入一個人

分析:

我是先掃一遍座位,有相鄰的1直接輸出No,如果沒有,掃第二遍,是否有3個連續的0,如果有輸出No,沒有 輸出Yes,值得注意的是開頭跟結尾為0的情況只要有連續2個0就直接輸出No,還有就是只有一個座位的時候在特 判一下

code:

#define debug #include<bits/stdc++.h> #define pb push_back #define dbg(x) cout<<#x<<" = "<<(x)<<endl; #define lson l,m,rt<<1 #define cmm(x) cout<<"("<<(x)<<")"; #define rson m+1,r,rt<<1|1 using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll>PLL; typedef pair<int,ll>Pil; const ll INF = 0x3f3f3f3f; const ll inf=0x7fffffff; const double eps=1e-8; const int maxn =1e6+10; const int N = 510; const ll mod=1e9+7; const ll MOD=1e9; //------ //define int a[maxn]; //solve void solve() {int n;while(cin>>n){string s;cin>>s;int len=s.size();if(len==1){if(s[0]=='1'){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}else{int flag=0;for(int i=0;i<n-1;i++){if(s[i]==s[i+1]&&s[i]=='1'){flag=1;break;}}if(flag){cout<<"No"<<endl;continue;}for(int i=0;i<n;i++){if(i==0&&s[i]==s[i+1]&&s[i]=='0'){flag=1;break;}if(i==n-1&&s[i]==s[i-1]&&s[i]=='0'){flag=1;break;}if(s[i]==s[i-1]&&s[i]==s[i+1]&&s[i]=='0'){flag=1;break;}}if(flag){cout<<"No"<<endl;}else{cout<<"Yes"<<endl;}}} }int main() {ios_base::sync_with_stdio(false); #ifdef debugfreopen("in.txt", "r", stdin); // freopen("out.txt","w",stdout); #endifcin.tie(0);cout.tie(0);solve();/*#ifdef debugfclose(stdin);fclose(stdout);system("out.txt");#endif*/return 0; }

  

  

?

轉載于:https://www.cnblogs.com/visualVK/p/9083893.html

總結

以上是生活随笔為你收集整理的Codeforces Round #484 (Div. 2) A. Row的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。