Girls and Historical Similarity of Strings
All submissions for this problem are available.
Isha asked to Suhana, what is historical similarity of two strings ?
Suhana says, "Two strings P and Q are historically similar if P can be converted into Q after applying following operation zero or more times."
In one operation, Isha can replace all occurences of a single character in P with any character from alphabet Z subject to following simple rules :
- Replace only happens when new character doesn't already exists in P.
- Replace operation is atomic to all occurences which means all occurences are replaced simultaneously with same character.
- All occurences must be replaced.
- Alphabet Z consists of lower case english letters only.
Isha says, "Wow, That's interesting. Never heard anything more easy than that."
Task is to determine if given two strings are historically similar ?
Isha already started coding, what are you upto ?
First line contains number of test cases.
Each test contains two space separated strings P and Q on same line.
For each test case output "YES" if P and Q are historically similar, otherwise output "NO".
- 1 ≤ T ≤ 100
- 1 ≤ length(P) == length(Q) ≤ 1000
- P and Q consists of lower case english letters only.
Input: 3 aa bb aab bba aba ccc Output: YES YES NO
In first test case, one possible transition can be :
- Replace 'a' with 'b' (P : bb, Q : bb).
- Replace 'a' with 'e' (P : eeb, Q : bba)
- Replace 'b' with 'a' (P : eea, Q : bba)
- Replace 'e' with 'b' (P : bba, Q : bba)
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions