Problem:


Score : 300 points

Problem Statement

You are given strings S and T consisting of lowercase English letters.

You can perform the following operation on S any number of times:

Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.

Determine if S and T can be made equal by performing the operation zero or more times.

Constraints

1 \leq |S| \leq 2 \times 10^5

|S| = |T|

S and T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

If S and T can be made equal, print Yes; otherwise, print No.

Sample Input 1

azzel
apple

Sample Output 1

Yes

azzel can be changed to apple, as follows:

Choose e as c_1 and l as c_2. azzel becomes azzle.

Choose z as c_1 and p as c_2. azzle becomes apple.

Sample Input 2

chokudai
redcoder

Sample Output 2

No

No sequences of operation can change chokudai to redcoder.

Sample Input 3

abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu

Sample Output 3

Yes



Sample input:
azzel
apple


Sample output:
Yes

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
T = input()
s_map = defaultdict(str)
t_map = defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if len(s_map[s]) > 0:
        if s_map[s] != t:
            ans = 'No'
    if len(t_map[t]) > 0:
        if t_map[t] != s:
            ans = 'No'
    s_map[s] = t
    t_map[t] = s

print(ans)

Submission status: Accepted

Solution code:
# 変換テーブルをbefore,afterと2つ使うのがポイント

s = input()
t = input()
 
before = [-1] * 26
after = [-1] * 26
 
for i, j in zip(s, t):
    si = ord(i) - ord('a')
    ti = ord(j) - ord('a')
 
    if before[si] != -1 or after[ti] != -1:
        if before[si] != ti or after[ti] != si:
            print("No")
            exit()
 
    before[si] = ti
    after[ti] = si
print("Yes")

Submission status: Accepted

Solution code:
A = {chr(i):0 for i in range(97,123)}
S = input().strip()
T = input().strip()
N = len(S)
G = {}
for i in range(N):
    a = S[i]
    if a not in G:
        G[a]=[]
    b = T[i]
    if b not in G[a]:
        G[a].append(b)
flag = 0
cnt = 0
for a in G:
    cnt += 1
    if len(G[a])>1:
        flag = 1
        break
    if len(G[a])==0 and cnt==26:
        break
    b = G[a][0]
    if a!=b:
        cnt += 1
    if A[b]==0:
        A[b] += 1
    else:
        flag = 1
        break
if flag==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

s=input()
t=input()

cs=Counter(s)
ct=Counter(t)

print('Yes' if sorted(cs.values())==sorted(ct.values()) else 'No')

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    T = input()

    dict1 = {}
    dict2 = {}
    for s, t in zip(S, T):
        if dict1.get(t) is not None and dict1[t] != s:
            print("No")
            exit()

        if dict2.get(s) is not None and dict2[s] != t:
            print("No")
            exit()

        dict1[t] = s
        dict2[s] = t

    print("Yes")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)

d = {chr(i):chr(i) for i in range(97,97+26)}

ans = 'Yes'
for i in range(N):
    now_si = d[S[i]]
    for k,v in d.items():
        if v == now_si:
            d[k] = T[i]
        elif v == T[i]:
            d[k] = now_si

for i in range(N):
    if d[S[i]] != T[i]:
        ans = 'No'


print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s_set = list(set(s))
t_set = list(set(t))

for j in range(len(s_set)):
    tmp = []
    for k in range(len(s)):
        if s_set[j] == s[k]:
            tmp.append(t[k])
    if len(set(tmp)) > 1:
        print('No')
        exit()

for p in range(len(t_set)):
    tmp = []
    for q in range(len(t)):
        if t_set[p] == t[q]:
            tmp.append(s[q])
    if len(set(tmp)) > 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
N=len(S)
D1={}
D2={}
count=0
for i in range(N):
    s=S[i]
    t=T[i]
    if s not in D1:
        D1[s]=count
        S[i]=count
    else:
        S[i]=D1[s]
    if t not in D2:
        D2[t]=count
        T[i]=count
        count+=1
    else:
        T[i]=D2[t]

for i in range(N):
    s=S[i]
    t=T[i]
    if s!=t:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
t = list(input())
ss = [s,t]
n = len(s)
res = [[],[]]
for i in range(2):
    d = defaultdict(int)
    cnt = 1
    for j,x in enumerate(ss[i]):
        if d[x] == 0:
            d[x] = cnt
            cnt += 1
        res[i].append(d[x])
print('Yes' if res[0] == res[1] else 'No')

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    T = input()

    dict = {}
    for s, t in zip(S, T):
        if dict.get(t) is not None and dict[t] != s:
            print("No")
            exit()
        else:
            dict[t] = s

    if len(set(dict.values())) == len(dict):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
S = input()
T = input()

def check():
    n = len(S)
    dic1,dic2 = {},{}
    for i in range(n):
        if T[i] not in dic1:
            dic1[T[i]] = S[i]
        elif dic1[T[i]] != S[i]:
            return 'No'
        if S[i] not in dic2:
            dic2[S[i]] = T[i]
        elif dic2[S[i]] != T[i]:
            return 'No'
    return 'Yes'
print(check())

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()


alphasm=[chr(i) for i in range(97, 97+26)]
s=input().rstrip()
t=input().rstrip()
u=Counter(list(s))
v=Counter(list(t))
a,b=[],[]
for i in alphasm:
    a.append(u[i])
    b.append(v[i])
a.sort()
b.sort()
if a==b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    S=readline().strip()
    T=readline().strip()

    d=dict()
    for i in range(len(S)):
        if S[i] not in d:
            d[S[i]]=T[i]
        else:
            if d[S[i]]!=T[i]:
                print("No")
                break
    else:
        li=list(d.items())
        d2=dict()
        for cs in li:
            c1=cs[0]
            c2=cs[1]
            if c2 not in d2:
                d2[c2]=c1
            else:
                if d2[c2]!=c1:
                    print("No")
                    break
        else:
            print("Yes")
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s)

slist = []
scount = []
tlist = []
tcount = []

for i in range(n):
  if not s[i] in slist:
    slist.append(s[i])
    scount.append(1)
  else:
    for j in range(len(slist)):
      if slist[j] == s[i]:
        scount[j] += 1
   
  if not t[i] in tlist:
    tlist.append(t[i])
    tcount.append(1)
  else:
    for j in range(len(tlist)):
      if tlist[j] == t[i]:
        tcount[j] += 1
        
print("Yes") if scount == tcount else print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s = sorted(Counter(list(input())).values())
t = sorted(Counter(list(input())).values())
print("Yes" if s==t else "No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import Counter

S = list(input())
T = list(input())

SC = Counter(S)
TC = Counter(T)

lstS = []
for s in SC:
    lstS.append(SC[s])

lstT = []
for t in TC:
    lstT.append(TC[t])

lstS.sort()
lstT.sort()

if lstS == lstT:
    print ('Yes')
else:
    print ('No')

Submission status: Accepted

Solution code:
S = input()
T = input()

def isOk():
    sToT = {}
    tToS = {}
    for s, t in zip(S, T):
        if not s in sToT:
            sToT[s] = t
        elif sToT[s] != t:
            return False
        if not t in tToS:
            tToS[t] = s
        elif tToS[t] != s:
            return False
    return True

print('Yes' if isOk() else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
cnt1 = [0]*26
cnt2= [0]*26
for x in s:
    cnt1[ord(x) - ord('a')] += 1
for x in t:
    cnt2[ord(x) - ord('a')] += 1
cnt1.sort()
cnt2.sort()
ok = True
for i in range(26):
    if cnt1[i] != cnt2[i]:
        ok = False
        break
if ok:print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()

s_alph_index = {}
for i in range(len(s)):
    if s[i] not in s_alph_index:
        s_alph_index[s[i]] = [i,]
    else:
        s_alph_index[s[i]].append(i)
t_alph_index = {}
for i in range(len(t)):
    if t[i] not in t_alph_index:
        t_alph_index[t[i]] = [i,]
    else:
        t_alph_index[t[i]].append(i)

for key, vals in s_alph_index.items():
    cur = t[vals[0]]
    for index in vals:
        if t[index] != cur:
            print('No')
            exit()

for key, vals in t_alph_index.items():
    cur = s[vals[0]]
    for index in vals:
        if s[index] != cur:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s_set = list(set(s))
t_set = list(set(t))
l = len(s)
l_s_set = len(s_set)
l_t_set = len(t_set)

x = [[] for _ in range(l)]
for i in range(l):
    x[i].append(s[i])
    x[i].append(t[i])

for j in range(l_s_set):
    tmp = []
    for k in range(l):
        if s_set[j] == x[k][0]:
            tmp.append(x[k][1])
    if len(set(tmp)) > 1:
        print('No')
        exit()

for p in range(l_t_set):
    tmp = []
    for q in range(l):
        if t_set[p] == x[q][1]:
            tmp.append(x[q][0])
    if len(set(tmp)) > 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
T = sr()
cnt_S = Counter(S)
cnt_T = Counter(T)
num_S = sorted(list(cnt_S.values()))
num_T = sorted(list(cnt_T.values()))

bl = num_S == num_T
print('Yes' if bl else 'No')

Submission status: Accepted

Solution code:
S = input()
T = input()
d = {}

for s, t in zip(S, T):
  if s in d:
    #含まれている場合で、tと異なるならば、変換ができないということ
    if d[s] != t:
      print("No")
      exit()
  else:
    d[s] = t

#keyの数に対し、valuesが重複していて、数が合わなければ、変換ができない
if len(d) != len(set(d.values())):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
li_s = list(s)
li_t = list(t)
ma = {}
ma_2 = {}
for i,j in zip(li_s,li_t):
    if j not in ma:
        ma[j] = i
    elif ma[j] != i:
        print('No')
        exit()

    if i not in ma_2:
        ma_2[i] = j
    elif ma_2[i] != j:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
n = len(s)
sp = []
tp = []
for i in range(n):
    if not s[i] in sp:
        sp.append(s[i])
    x = sp.index(s[i])
    if not t[i] in tp:
        tp.append(t[i])
    y = tp.index(t[i])
    
    if x != y:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

s=input().rstrip()
t=input().rstrip()
u=Counter(s)
v=Counter(t)
for i in range(len(s)):
    if u[s[i]]!=v[t[i]]:
        print("No")
        #print(i)
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
s = Counter(input())
t = Counter(input())
sc = sorted([x for x in s.values()])
tc = sorted([x for x in t.values()])
print("Yes" if sc==tc else "No")

Submission status: Accepted

Solution code:
s = input()
t = input()
S = sorted(map(s.count, set(s)))
T = sorted(map(t.count, set(t)))
print("Yes" if S==T else "No")

Submission status: Accepted

Solution code:
import sys
s = input()
t = input()
v = {}
for i, c in enumerate(s):
  if s[i] not in v:
    v[s[i]] = t[i]
  elif v[s[i]] != t[i]:
    print('No')
    sys.exit()
  else:
    v[s[i]] = t[i]
st = set()
for x in v.values():
  if x in st:
    print('No')
    sys.exit()
  else:
    st.add(x)
print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

S = input()
T = input()

s_t = {}
t_s = {}

for s, t in zip(S, T):
    if s not in s_t:
        s_t[s] = t
    else:
        if s_t[s] != t:
            print("No") 
            exit()
            
    if t not in t_s:
        t_s[t] = s
    else:
        if t_s[t] != s:
            print("No") 
            exit()
print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
S = sorted(map(s.count, set(s)))
T = sorted(map(t.count, set(t)))
print('Yes' if S == T else 'No')

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = collections.Counter(iss())
    T = collections.Counter(iss())

    if sorted(S.values()) == sorted(T.values()):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
t=input()
d={}
for i in range(len(s)):
    if s[i] in d.keys():
        if d[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        if t[i] in d.values():
            print("No")
            exit()
        else:
            d[s[i]]=t[i]

print("Yes")

Submission status: Accepted

Solution code:
def cn(s):
    return ord(s)-ord("a")
s  = input()
t  = input()
alp = "abcdefghijklmnopqrstuvwxyz"
arr = [-1]*26
arrt = [-1]*26
f =True
for i in range(len(s)):
    if arr[cn(s[i])] ==-1:
        arr[cn(s[i])] = cn(t[i])
    elif arr[cn(s[i])] != cn(t[i]):
        f=False
        break
for i in range(len(s)):
    if arrt[cn(t[i])] ==-1:
        arrt[cn(t[i])] = cn(s[i])
    elif arrt[cn(t[i])] != cn(s[i]):
        f=False
        break

print("Yes") if f else print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
dicST={}
dicTS={}

for i,j in zip(s,t):
  if (dicTS.get(j,0) != 0 and dicTS[j] != i) or \
    (dicST.get(i,0) != 0 and dicST[i] != j):
    print("No")
    break
  else:
    dicTS[j] = i
    dicST[i] = j
else:
  print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

S_dict, T_dict = defaultdict(list), defaultdict(list)
for i, s in enumerate(S):
    S_dict[s].append(i)
for i, t in enumerate(T):
    T_dict[t].append(i)

S_set, T_set = set(), set()
for s in S_dict.values():
    S_set.add(tuple(s))
for t in T_dict.values():
    T_set.add(tuple(t))

print('Yes' if S_set == T_set else 'No')

Submission status: Accepted

Solution code:
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

n = len(s)

from collections import defaultdict
ds = defaultdict(list)
dt = defaultdict(list)

for i in range(n):
    if s[i] in ds.keys():
        if ds[s[i]] != t[i]:
            print('No')
            exit()
    else:
        ds[s[i]] = t[i]

for i in range(n):
    if t[i] in dt.keys():
        if dt[t[i]] != s[i]:
            print('No')
            exit()
    else:
        dt[t[i]] = s[i]

print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
d = {}

for s, t in zip(S, T):
  if s in d:
    if d[s] != t:
      print("No")
      exit()
  else:
    d[s] = t

if len(d) != len(set(d.values())):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
import sys
S=input()
T=input()
start=[-1 for i in range(26)]
goal=[-1 for i in range(26)]
alp=[i for i in "abcdefghijklmnopqrstuvwxyz"]
for i in range(len(S)):
  ind_s=alp.index(S[i])
  ind_t=alp.index(T[i])

  if start[ind_s]!=-1 or goal[ind_t]!=-1:
    if start[ind_s]!=ind_t or goal[ind_t]!=ind_s:
      print("No")
      sys.exit()
  else:
    start[ind_s]=ind_t
    goal[ind_t]=ind_s
print("Yes")

Submission status: Accepted

Solution code:
import sys

S = input()
T = input()

d_T = {}
d_S = {}

for i in range(len(S)):
    if T[i] in d_T and d_T[T[i]]!=S[i]:
        print("No")
        sys.exit()
    d_T[T[i]] = S[i]

for i in range(len(T)):
    if S[i] in d_S and d_S[S[i]]!=T[i]:
        print("No")
        sys.exit()
    d_S[S[i]] = T[i]


print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()

dcts = {}
dctt = {}
jdg = True

for i, s in enumerate(S):
    if s in dcts.keys():
        if dcts[s]!=T[i]:
            jdg = False
            break
    else: dcts[s] = T[i]
    if T[i] in dctt.keys():
        if dctt[T[i]]!=s:
            jdg = False
            break
    else: dctt[T[i]] = s
print('Yes' if jdg else 'No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
import sys


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    d1 = defaultdict(set)
    for i, si in enumerate(S):
        d1[si].add(i)
    d2 = defaultdict(set)
    for i, ti in enumerate(T):
        d2[ti].add(i)
    print(
        YES if
        set(frozenset(s) for s in d1.values()) ==
        set(frozenset(s) for s in d2.values())
        else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#n=int(input())
#a,b=map(int,input().split())
sl=list(input())
tl=list(input())
#l=[list(map(int,input().split())) for i in range(n)]

sdic={}
tdic={}
flag=True
for i in range(len(sl)):
    s=sl[i]
    t=tl[i]
    if sdic.get(s,-1)==-1:
        sdic[s]=t
    else:
        if sdic[s]!=t:
            flag=False
            break
    if tdic.get(t,-1)==-1:
        tdic[t]=s
    else:
        if tdic[t]!=s:
            flag=False
            break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')


def solve():
    S = list(input())
    T = list(input())

    ds = {}
    dt = {}
    ids = ''
    idt = ''
    cids = 0
    cidt = 0
    for i in range(len(S)):
        # S
        s = S[i]
        if s in ds:     # 出現済みの文字なら、その文字のIDを追加する
            idss = ds[s]
            ids = ids + str(idss)
        else:           # 新たに出現した文字なら、新しいIDを追加し、メモしておく
            cids += 1
            ds[s] = cids
            ids = ids + str(cids)

        # T
        t = T[i]
        if t in dt:
            idst = dt[t]
            idt = idt + str(idst)
        else:
            cidt += 1
            dt[t] = cidt
            idt = idt + str(cidt)

        if ids != idt:
            print('No')
            return

    print('Yes')



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(input())
    T = list(input())

    ds = {}
    dt = {}
    ids = ''
    idt = ''
    cids = 0
    cidt = 0
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s in ds:
            idss = ds[s]
            ids = ids + str(idss)
        else:
            cids += 1
            ds[s] = cids
            ids = ids + str(cids)

        if t in dt:
            idst = dt[t]
            idt = idt + str(idst)
        else:
            cidt += 1
            dt[t] = cidt
            idt = idt + str(cidt)

    print('Yes' if ids == idt else 'No')



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
s=input()
t=input()
ns,nt=0,0
anss,anst=s,t
sl,tl=[],[]
for i in range(len(s)):
    if s[i] in sl:
        pass
    else:
        ns+=1
        sl.append(s[i])
        anss=anss.replace(s[i],str(ns))
    if t[i] in tl:
        pass
    else:
        nt+=1
        tl.append(t[i])
        anst=anst.replace(t[i],str(nt))
print('Yes' if anss==anst else 'No')

Submission status: Accepted

Solution code:
s=input()
t=input()

a="abcdefghijklmnopqrstuvwxyz"
rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn="Yes"
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break       
print(yn)

Submission status: Accepted

Solution code:
s=input()
t=input()

a=list("abcdefghijklmnopqrstuvwxyz")

rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn="Yes"
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break
        
print(yn)

Submission status: Accepted

Solution code:

s=list(input())
t=list(input())

a=list("abcdefghijklmnopqrstuvwxyz")

rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn=""
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break
        
if yn=="No":
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s1 = input()
s2 = input()
dict_s1 = {}
dict_s2 = {}
for i in range(len(s1)):
    if s1[i] not in dict_s1:
        dict_s1[s1[i]] = s2[i]
    else:
        if dict_s1[s1[i]] != s2[i]:
            print('No')
            quit()
    if s2[i] not in dict_s2:
        dict_s2[s2[i]] = s1[i]
    else:
        if dict_s2[s2[i]] != s1[i]:
            print('No')
            quit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()

st = defaultdict(lambda :0)
for x, y in zip(s,t):
    if (st[(y, 1)] != 0 and st[(y, 1)] != x) or (st[(x, 0)] != 0 and st[(x, 0)] != y):
        #print(x,y)
        print('No')
        exit()
    st[(y, 1)] = x
    st[(x, 0)] = y

print('Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()

s_t=[-1]*26
t_s=[-1]*26

for i in range(len(s)):
    num_s=ord(s[i])-97
    num_t=ord(t[i])-97
    
    if s_t[num_s]==-1 and t_s[num_t]==-1:
        s_t[num_s]=num_t
        t_s[num_t]=num_s
    elif s_t[num_s]!=num_t or t_s[num_t]!=num_s:
        print("No")
        exit()
    
print("Yes")

Submission status: Accepted

Solution code:
s1 = input()
s2 = input()
dic = {}
for i in range(len(s1)):
    if not s1[i] in dic:
        dic[s1[i]] = s2[i]
    else:
        if dic[s1[i]] != s2[i]:
            print('No')
            quit()
#print('Yes')
if len(dic) != len(set(dic.values())):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = input()

def checker(s,t):
    alphabets = [None] * 26
    for i,j in zip(s,t):
        order_number = ord(i) - ord("a")
        if alphabets[order_number] == None:
            alphabets[order_number] = j
        else:
            if alphabets[order_number] != j:
                return False
    return True

if checker(s,t) and checker(t,s):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S,T = input(),input()

convert = dict()

bl = True
for s,t in zip(S,T):
  if s in convert and convert[s] != t:
    bl = False
    break
  convert[s] = t

# 変換先の重複チェック
after = convert.values()
if len(after) != len(set(after)):
  bl = False

print('Yes' if bl else 'No')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc110/tasks/abc110_c

def main():
    s = input()
    t = input()

    d = {}
    for i in range(len(s)):
        if t[i] in d and d[t[i]] != s[i]:
            print('No')
            return
        elif t[i] not in d:
            d[t[i]] = s[i]
    d = {}
    for i in range(len(s)):
        if s[i] in d and d[s[i]] != t[i]:
            print('No')
            return
        elif s[i] not in d:
            d[s[i]] = t[i]
    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
T = input()
# print(S, T)

# NUMBER_OF_ALPHABETS = 26
# S_length = len(S)
# if S_length < NUMBER_OF_ALPHABETS:
#     print('Yes')
#     exit()

ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
answer = 'Yes'
for alphabet in ALPHABETS:
    i = S.find(alphabet)
    if i == -1: continue

    replaced_S = S.replace(S[i], '')
    replaced_T = T.replace(T[i], '')
    # print(replaced_S, replaced_T)
    if len(replaced_S) != len(replaced_T):
        answer = 'No'
        break
print(answer)

# for i in range(S_length):
#     replaced_S = S.replace(S[i], '')
#     replaced_T = T.replace(T[i], '')
#     if len(replaced_S) != len(replaced_T):
#         answer = 'No'
#         break
# print(answer)

# 同一文字は同一位置でなければならない
# 未使用文字が存在する場合: スワップしながら可能か？
# 未使用文字が存在しない場合: 他文字と被るかどうか？

Submission status: Accepted

Solution code:
import string


S = list(input())
T = list(input())

ans = "Yes"
tableT = []
for i in range(26):
  tableT.append("0")


for i in range(len(S)):
  s = ord(S[i])-97
  if tableT[s] == "0":
    tableT[s] = T[i]
  else:
    if tableT[s] != T[i]:
      ans = "No"
      break


tableS = []
for i in range(26):
  tableS.append("0")



for i in range(len(S)):
  t = ord(T[i])-97
  if tableS[t] == "0":
    tableS[t] = S[i]
  else:
    if tableS[t] != S[i]:
      ans = "No"
      break

print(ans)

Submission status: Accepted

Solution code:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    T = list(iss())
    StoT = {}
    TtoS = {}
    for n in range(ord('a'), ord('z') + 1):
        StoT[chr(n)] = 0
        TtoS[chr(n)] = 0

    for st in zip(S, T):
        s, t = st
        if StoT[s] == 0 and TtoS[t] == 0:
            StoT[s] = t
            TtoS[t] = s
        elif StoT[s] != t or TtoS[t] != s:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = list(iss())
    B = list(iss())
    atob = {}
    btoa = {}
    for n in range(ord('a'), ord('z') + 1):
        atob[chr(n)] = 0
        btoa[chr(n)] = 0

    for ab in zip(A, B):
        a, b = ab
        if atob[a] == 0 and btoa[b] == 0:
            atob[a] = b
            btoa[b] = a
        elif atob[a] != b or btoa[b] != a:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())

from collections import defaultdict
ds=defaultdict(list)
dt=defaultdict(list)

for i in range(len(s)):
    if t[i] not in ds[s[i]]:
        ds[s[i]].append(t[i])
    if s[i] not in dt[t[i]]:
        dt[t[i]].append(s[i])

for k in ds.keys():
    if len(ds[k])>1:
        print('No')
        exit()
for k in dt.keys():
    if len(dt[k])>1:
        print('No')
        exit()
print('Yes')