Advertisement
ekzolot

Untitled

Apr 15th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main(){
  5.     int n;
  6.     cin>>n;
  7.     vector <char> a(n);
  8.     for (int i=0; i<n; i++){
  9.         cin>>a[i];
  10.     }
  11.     int b=0;
  12.     int c=0;
  13.     for (int i=0; i<n-1; i++){
  14.         if (a[i]==a[i+1]){
  15.             if (a[i]==0){
  16.                 b++;
  17.             }
  18.             else{
  19.                 c++;
  20.             }
  21.         }
  22.     }
  23.     if (b==0 || c==0){
  24.         cout<<"Yes";
  25.     }
  26.     else{
  27.         cout<<"No";
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement