Saleh127

Untitled

Apr 15th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int b,c=1,d,e,f,i,j,k,l;
  6. string a;
  7. cin>>b;
  8. cin>>a;
  9. if((b==1 && a[0]=='0')|| (a[0]=='0' && a[1]=='0') || (a[b-1]=='0' && a[b-2]=='0'))
  10. {
  11. cout<<"No\n";
  12. return 0;
  13. }
  14. for(i=0; i<b-1; i++)
  15. {
  16. if((a[i]=='1' && a[i]==a[i+1])||(a[i]=='0'&&a[i]==a[i-1] && a[i]==a[i+1]))
  17. {
  18. cout<<"No\n";
  19. return 0;
  20. }
  21. }
  22. cout<<"Yes\n";
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment