Advertisement
amine99

Untitled

Mar 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define itloop(it,x) for(auto it=x.begin();it!=x.end();it++)
  5. #define reloop(i,e,b) for(auto i=e;i>=b;i--)
  6. #define loop(i,b,e) for(auto i=b;i<=e;i++)
  7. #define ALL(x) x.begin(),x.end()
  8. #define SZ(x) x.size()
  9. #define PB push_back
  10. #define MP make_pair
  11. #define F first
  12. #define S second
  13. #define sf scanf
  14. #define pf printf
  15. typedef long long LL;
  16. typedef vector<int> VI;
  17. typedef vector<LL> VLL;
  18. typedef pair<int,int> PI;
  19. typedef pair<LL,LL> PL;
  20.  
  21. int n,un,x,y,z;
  22. string c;
  23.  
  24. int main()
  25. {
  26.    cin >> n >> c;
  27.    loop(i,0,c.length()-1) {
  28.       if(c[i] == '?')
  29.          un++;
  30.    }
  31.    if(un == 0 || un == 1)
  32.       cout << "No";
  33.    else {
  34.       loop(i,0,c.length()-1) {
  35.          if(c[i] == '?') {
  36.             if(c[i-1] != 'C' && c[i+1] != 'C')
  37.                c[i] = 'C',x++;
  38.             if(c[i-1] != 'Y' && c[i+1] != 'Y')
  39.                c[i] = 'Y',y++;
  40.             if(c[i-1] != 'M' && c[i+1] != 'M')
  41.                c[i] = 'M',z++;
  42.          }
  43.       }
  44.       puts(min(x,min(y,z)) == 0 ? "Yes" : "No");
  45.    }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement