Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cassert>
- #include <iostream>
- using namespace std;
- const int MAX_N = 105;
- int main() {
- ifstream fin("cristale.in");
- ofstream fout("cristale.out");
- char s[MAX_N];
- int T, N;
- char x, y, z;
- fin >> x >> y >> z;
- fin >> T;
- while (T--) {
- fin >> N >> s;
- int one = 0, two = 0, three = 0;
- for (int i = 0; i < N; ++i) {
- if (s[i] == x)
- one++;
- if (s[i] == y)
- two++;
- if (s[i] == z)
- three++;
- }
- if (one < N && two < N && three < N) {
- if (one == two && two == three) {
- fout << 2 << endl;
- } else {
- fout << 1 << endl;
- }
- } else {
- fout << N << endl;
- }
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement