-
Notifications
You must be signed in to change notification settings - Fork 0
/
SNELECT.java
48 lines (42 loc) · 895 Bytes
/
SNELECT.java
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
import java.util.*;
import java.lang.*;
class SNELECT
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t;
t=sc.nextInt();
while(t--!=0)
{
int s=0,m=0,kill=0;
String a;
a=sc.next();
int l=a.length();
char snake='s',mangoose='m';
for(int i=0;i<l;i++)
{
if(a.charAt(i)==snake)
s++;
if(a.charAt(i)==mangoose)
m++;
}
for(int i=1; i<l;i++) {
if(!(a.charAt(i)==a.charAt(i-1))) {
kill++;
++i;
}
}
s-=kill;
if(s < m){
System.out.println("mongooses");
}
else if(s > m){
System.out.println("snakes");
}
else{
System.out.println("tie");
}
}
}
}