fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n;
  5.  
  6. bool is_there(string str, char ch){
  7. for (int i=0; str.size()>i; i++){
  8. if (ch==str[i]){
  9. return false;
  10. }
  11. }
  12. return true;
  13. }
  14.  
  15. int main(){
  16. bool status = false;
  17. //no violation of rules
  18. cin >> n;
  19. string lst[n];
  20. char first[n];
  21. char last[n];
  22. for (int i=0; n>i; i++){
  23. cin >> lst[i];
  24. first[i] = lst[i][0];
  25. last[i] = lst[i][1];
  26. }
  27. sort(lst, lst+n);
  28. for (int i=0; n-1>i; i++){
  29. if (lst[i] == lst[i+1]){
  30. status = true;
  31. }
  32. }
  33. string r1="HDCS";
  34. string r2="A23456789TJQK";
  35.  
  36. for (int i=0; n>i; i++){
  37. if (is_there(r1, first[i])){
  38. status = true;
  39. }
  40. if (is_there(r2, last[i])){
  41. status = true;
  42. }
  43. }
  44. if (status){
  45. cout << "No";
  46. }
  47. else{
  48. cout << "Yes";
  49. }
  50. }
Success #stdin #stdout 0.01s 5348KB
stdin
5
00
AA
XX
YY
ZZ
stdout
No