| Task: | Swapping letters |
| Sender: | Wu xiaobo |
| Submission time: | 2020-09-20 01:27:45 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.10 s | details |
| #2 | RUNTIME ERROR | 0.09 s | details |
| #3 | RUNTIME ERROR | 0.10 s | details |
| #4 | RUNTIME ERROR | 0.10 s | details |
| #5 | RUNTIME ERROR | 0.10 s | details |
| #6 | RUNTIME ERROR | 0.10 s | details |
| #7 | RUNTIME ERROR | 0.10 s | details |
| #8 | RUNTIME ERROR | 0.09 s | details |
| #9 | RUNTIME ERROR | 0.10 s | details |
| #10 | RUNTIME ERROR | 0.10 s | details |
Code
# n = int(input())
#
# forbidden = {}
# for _ in range(n):
# a, b = input().split()
# if a not in forbidden:
# forbidden[a] = {b}
# else:
# forbidden[a].add(b)
#
# if b not in forbidden:
# forbidden[b] = {a}
# else:
# forbidden[a].add(a)
#
# x = input()
# y = input()
#
# if len(x) != len(y):
# print('NO')
# else:
# # letters = set(x)
# # for l in letters:
# # if x.count(l) != y.count(l):
# # print('NO')
# # break
# # else:
# for i in range(len(x)):
# if x[i] == y[i]:
# continue
# ind = i + x[i+1:].index(y[i]) + 1
# for j in range(i, ind):
# if y[i] in forbidden and x[j] in forbidden[y[i]]:
# break
# else:
# x = x[:i] + x[ind] + x[i:ind] + x[ind + 1:]
# continue
# print('NO')
# break
# else:
# print('YES')
import profile
def main():
with open('./test_input.txt', 'r') as f:
n = int(f.readline())
forbidden = []
for _ in range(n):
a, b = f.readline().split()
forbidden.append([a, b])
x = f.readline().strip()
y = f.readline().strip()
import time
start = time.time()
# n = int(input())
# forbidden = []
# for _ in range(n):
# a, b = input().split()
# forbidden.append([a, b])
#
# x = input()
# y = input()
print(x)
print(y)
letters = 'abcdefghijklmnopqrstuvwxyz'
x_letters = {l: [] for l in letters}
y_letters = {l: [] for l in letters}
for i, l in enumerate(x):
x_letters[l].append(i)
for i, l in enumerate(y):
y_letters[l].append(i)
ta = time.time()
print(ta - start)
# if len(x) != len(y):
# print('NO')
# else:
for a, b in forbidden:
ind_x = sorted(x_letters[a] + x_letters[b])
ind_y = sorted(y_letters[a] + y_letters[b])
for i in range(len(ind_x)):
if x[ind_x[i]] != y[ind_y[i]]:
break
else:
continue
print('NO')
break
else:
print('YES')
end = time.time()
print(end - start)
profile.run('main()')
Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| 5 a b b c c d d e ... |
| correct output |
|---|
| YES |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 2 a b b c acbbaca cabbaac |
| correct output |
|---|
| YES |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 2 a b b c acbbaca baccaab |
| correct output |
|---|
| NO |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 10 d c e b f y h q ... |
| correct output |
|---|
| YES |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 10 a i a l d a g h ... |
| correct output |
|---|
| NO |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 325 a b a e a f a g ... |
| correct output |
|---|
| YES |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 325 a c a e a g a h ... |
| correct output |
|---|
| NO |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| 0 dlkinfmdyjaofxbccwhhbxzartqwdr... |
| correct output |
|---|
| YES |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| 0 bxisdrdpgcsnnvhnfgimivzqpqjwqc... |
| correct output |
|---|
| NO |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 0 mrwduerojcguvxzmbomfsainvqehsl... |
| correct output |
|---|
| NO |
| user output |
|---|
| 7 function calls in 0... Truncated |
Error:
Traceback (most recent call last):
File "input/code.py", line 101, in <module>
profi...