forked from Prince-1501/Hello_world-Competiitve-Programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
37_codechef_spell_bob.cpp
64 lines (59 loc) · 1.34 KB
/
37_codechef_spell_bob.cpp
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
53
54
55
56
57
58
59
60
61
62
//
// main.cpp
// Lecture 37
//
// Created by Prince Kumar on 17/04/19.
// Copyright © 2019 Prince Kumar. All rights reserved.
//
// CODE-CHEF
// --- ** Problems on Spell bob ** --- //
#include <iostream>
using namespace std;
int main()
{
int T; cin>>T;
while(T--)
{
string s1,s2; cin>>s1>>s2;
int a[3]={0}; // b count
for(int i=0;i<3;i++) // 'b' present or not
{
if(s1[i]=='b' || s2[i]=='b')
a[i]=1;
}
int b_count=0;
for(int i=0;i<3;i++)
{
if(a[i]==1)
b_count++;
}
if(b_count<=1)
cout<<"no"<<endl;
else if(b_count==2)
{
int index=0;
for(int i=0;i<3;i++)
{
if(a[i]==0)
index=i;
}
if(s1[index]=='o' || s2[index]=='o')
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
else if(b_count==3)
{
int o_count=0;
for(int i=0;i<3;i++)
{
if(s1[i]=='o' || s2[i]=='o')
o_count++;
}
if(o_count==0)
cout<<"no"<<endl;
else
cout<<"yes"<<endl;
}
}
}