fork download
  1. #include <cstring>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int arr[26] = {0,};
  11. char *input = new char;
  12. int check = 0;
  13. int loop;
  14. bool bloop = true;
  15. scanf("%d", &loop);
  16.  
  17. for( int i = 0; i < loop ; i++ )
  18. {
  19. scanf("%s",input);
  20. bloop = true;
  21. for( int j = 0; j < strlen(input); j++ )
  22. {
  23. if( arr[input[j] - 97] == 0 )
  24. {
  25. arr[input[j] - 97] = 1;
  26. }
  27. else if( arr[j] == 1 )
  28. {
  29. for( int k = 0; k < j ; k++ )
  30. {
  31. if( input[k] == input[j] )
  32. {
  33. if( input[k] != input[k+1] )
  34. {
  35. bloop = false;
  36. break;
  37. }
  38. }
  39. }
  40. }
  41. if( bloop == false )
  42. {
  43. break;
  44. }
  45. }
  46. if( bloop == true )
  47. {
  48. check++;
  49. }
  50. }
  51. printf("%d",check);
  52. return 0;
  53. }
Success #stdin #stdout 0s 4520KB
stdin
4
aba
abab
abcabc
a
stdout
4