-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquestion10.c
52 lines (44 loc) · 868 Bytes
/
question10.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
http://practice.geeksforgeeks.org/problems/the-smurfs/0
The smurfs
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int checkSmurfs(int rcount, int gcount, int bcount, char *str){
int n = rcount + gcount + bcount;
if(rcount == n || gcount == n || bcount == n){
return n;
}
if(((rcount & 1) && (bcount & 1) && (gcount & 1)) || (!(rcount & 1) && !(bcount & 1) && !(gcount & 1))){
return 2;
}
return 1;
}
int main(){
int cases;
scanf("%d",&cases);
int i;
for(i=0;i<cases;i++){
int n;
scanf("%d",&n);
int j;
char str[3000];
getchar();
int rcount = 0, gcount = 0, bcount = 0;
for(j=0;j<2*n;j++){
scanf("%c",&str[j]);
if(str[j] == 'R'){
rcount++;
}
if(str[j] == 'G'){
gcount++;
}
if(str[j] == 'B'){
bcount++;
}
}
printf("%d\n", checkSmurfs(rcount, bcount, gcount,str));
}
return 0;
}