-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChefAug4.cpp
More file actions
55 lines (54 loc) · 874 Bytes
/
ChefAug4.cpp
File metadata and controls
55 lines (54 loc) · 874 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
48
49
50
51
52
53
54
#include<bits/stdc++.h>
#define test int t;scanf("%d",&t);while(t--)
#define loop(i,a,b) for(i=a;i<b;i++)
#define pii pair<int,long int>
#define pli pair<long int,int>
using namespace std;
int main()
{
test
{
string p,q;
int a[27],b[27],i,j;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
cin>>p>>q;
loop(i,0,p.length())
{
a[p[i]-'a']++;
b[q[i]-'a']++;
}
loop(i,0,26)
{
//printf("%c %d %d\n",97+i,a[i],b[i]);
if(a[i]>1)
{
if(b[i]<1)
break;
}
}
bool subset=true,exactly=true;
loop(j,0,26)
{
//printf("%c %d %d\n",97+j,a[j],b[j]);
if(a[j]>=1&&b[j]>=1)
subset=true;
else if(b[j]==0&&a[j]!=0)
exactly=false;
else if(a[j]==0&&b[j]!=0)
{
//printf("%d",j);
exactly=false;subset=false;break;
}
}
if(!exactly&&subset)
{
printf("A\n");continue;
}
if(i==26||exactly)
printf("B\n");
else
printf("A\n");
}
return 0;
}