Advertisement
cosminBoaca

Untitled

Apr 30th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <fstream>
  2. #include <cassert>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. const int MAX_N = 105;
  7.  
  8. int main() {
  9. ifstream fin("cristale.in");
  10. ofstream fout("cristale.out");
  11.  
  12. char s[MAX_N];
  13. int T, N;
  14. char x, y, z;
  15.  
  16. fin >> x >> y >> z;
  17.  
  18. fin >> T;
  19.  
  20. while (T--) {
  21. fin >> N >> s;
  22.  
  23. int one = 0, two = 0, three = 0;
  24.  
  25. for (int i = 0; i < N; ++i) {
  26. if (s[i] == x)
  27. one++;
  28. if (s[i] == y)
  29. two++;
  30. if (s[i] == z)
  31. three++;
  32. }
  33.  
  34. if (one < N && two < N && three < N) {
  35. if (one == two && two == three) {
  36. fout << 2 << endl;
  37. } else {
  38. fout << 1 << endl;
  39. }
  40. } else {
  41. fout << N << endl;
  42. }
  43. }
  44.  
  45. fin.close();
  46. fout.close();
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement