-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnelect.cpp
More file actions
47 lines (46 loc) · 718 Bytes
/
snelect.cpp
File metadata and controls
47 lines (46 loc) · 718 Bytes
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
#include<iostream>
using namespace std;
int T,i;
char s[100];
int ar[100];
int main(){
cin>>T;
while (T--){
cin>>s;
int l=0,ct=0,m=0,sn=0;
for(i=0;s[i]!='\0';i++){
ar[i]=0;
l+=1;
}
for(i=0;s[i]!='\0';i++){
if (s[i]=='m' && ar[i]!=1 && l>1){
if (i>0 && s[i-1]=='s' && ar[i-1]==0) {
ar[i-1]=-1;
ar[i]=1;
}
else if(i<l && s[i+1]=='s' && ar[i+1]==0){
ar[i+1]=-1;
ar[i]=1;
}
}
}
for(i=0;s[i]!='\0';i++){
if (ar[i]==-1)
ct+=1;
}
for(i=0;s[i]!='\0';i++){
if (s[i]=='m')
m+=1;
else
sn+=1;
}
sn-=ct;
if (m>sn)
cout<<"mongooses\n";
else if(sn>m)
cout<<"snakes\n";
else
cout<<"tie\n";
}
return 0;
}