-
Notifications
You must be signed in to change notification settings - Fork 2
/
PALINGAM.cpp
executable file
·40 lines (40 loc) · 955 Bytes
/
PALINGAM.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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string s,t;
int a[26]={0},b[26]={0},uniques2=1,allequal=1,uniques=0,uniquet=0;
cin>>s>>t;
for(int i=0;s[i]!='\0';i++)
{
a[s[i]-'a']++;
b[t[i]-'a']++;
}
for(int i=0;i<26;i++)
{
if(allequal)
{
if(a[i]!=b[i])
allequal=0;
}
if(b[i]==0&&a[i]>1&&uniques2!=2)
uniques2=2;
if(b[i]==0&&a[i])
uniques=1;
if(a[i]==0&&b[i]>0&&!uniquet)
uniquet=1;
}
if(allequal)
cout<<"B"<<endl;
else if(uniques2==2)
cout<<"A"<<endl;
else if(uniques&&uniquet==0)
cout<<"A"<<endl;
else
cout<<"B"<<endl;
}
}