Submission #3820118


Source Code Expand

# -*- coding: utf-8 -*-


def answer(S, T, N):
    i = 0
    while i < N:
        c1 = S[i]
        c2 = T[i]
        # print("c1:", str(c1))
        # print("c2:", str(c2))
        if c1 != c2:
            for j in range(N):
                # print([S[j], c1])
                # print([T[j], c2])
                if S[j] == c1 and T[j] != c2:
                    return False
        i += 1

    return True


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

N = len(S)

ST = [None] * N

for i in range(N):
    ST[i] = [S[i], T[i]]

ST.sort(key=lambda a_i: a_i[0])

for i in range(N):
    S[i] = ST[i][0]
    T[i] = ST[i][1]

ans1 = answer(S, T, N)

ST.sort(key=lambda a_i: a_i[1])

for i in range(N):
    S[i] = ST[i][0]
    T[i] = ST[i][1]

# print(S)
# print(T)

ans2 = answer(T, S, N)

if ans1 and ans2:
    print("Yes")
else:
    print("No")

Submission Info

Submission Time
Task C - String Transformation
User CabochaSoup
Language Python (3.4.3)
Score 0
Code Size 890 Byte
Status TLE
Exec Time 2105 ms
Memory 30048 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 12
TLE × 12
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All 0_min0, 0_min1, 1_small0, 1_small1, 1_small2, 2_medium0, 2_medium1, 2_medium2, 2_medium3, 2_medium4, 3_max0, 3_max1, 3_max2, 3_max3, 3_max4, 3_max5, 3_max6, 3_max7, 3_max8, 3_max9, 5_hand0, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_min0 AC 18 ms 3064 KB
0_min1 AC 18 ms 3064 KB
1_small0 AC 18 ms 3064 KB
1_small1 AC 18 ms 3064 KB
1_small2 AC 18 ms 3064 KB
2_medium0 AC 342 ms 24080 KB
2_medium1 TLE 2105 ms 21492 KB
2_medium2 TLE 2104 ms 7924 KB
2_medium3 TLE 2105 ms 27152 KB
2_medium4 TLE 2105 ms 22548 KB
3_max0 AC 471 ms 30048 KB
3_max1 TLE 2105 ms 29960 KB
3_max2 TLE 2105 ms 30048 KB
3_max3 TLE 2105 ms 29996 KB
3_max4 TLE 2105 ms 29716 KB
3_max5 AC 342 ms 29096 KB
3_max6 TLE 2105 ms 29096 KB
3_max7 TLE 2105 ms 29016 KB
3_max8 TLE 2105 ms 29096 KB
3_max9 TLE 2104 ms 29016 KB
5_hand0 AC 18 ms 3064 KB
sample_01 AC 18 ms 3064 KB
sample_02 AC 18 ms 3064 KB
sample_03 AC 18 ms 3064 KB