-
Notifications
You must be signed in to change notification settings - Fork 1
/
codechef recipie2.cpp
94 lines (75 loc) · 1.69 KB
/
codechef recipie2.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
main()
{
int n=0;
scanf("%d",&n);
// while(n>0)
//{ cout<<"********";
begin:;
char s[25],a[15],b[10];
cin.getline(s,25,'\n');
//////////////// s-split to a & b
int i=0,j=0,flag=0;
while(s[i]!='\0')
{
if(s[i]==' ')
{flag=1;
goto lable;}
if(flag==0)
{ a[i]=s[i];
}
else
{b[j]=s[i];
j++;
}
lable:;
i++;
}
//////////////////
getch();
int p=0,q=0;
for(p=0;p<=(i-j-2);p++)
{
// case 1
int count=0;
for(q=0;q<=j;q++)
{
if(a[p]==b[q])
count++;
}
if(count==0)
{
cout<<"YES";
exit(0);
}
}
// case 1 done
// case 2&3
int count2=0,count1=0,p1=0;
for(p=0;p<=(i-j-2);p++)
{
char ch=a[p];
for(p1=0;p1<=(i-j-2);p1++)
{
if(a[p1]==ch)
count1++;
}
for(q=0;q<=j;q++)
{
if(b[q]==ch)
count2++;
}
if(count1!=count2)
{
cout<<"NO";
getch();
exit(0); }
}
cout<<"YES";
n--;
if(n>0)
goto begin;
getch();
}