Submission details
Task:Swapping letters
Sender:FiratKiyak
Submission time:2018-09-15 15:41:16 +0300
Language:Python2
Status:READY
Result:
Test results
testverdicttime
#10.03 sdetails
#20.03 sdetails
#30.04 sdetails
#4--details
#5--details
#6--details
#7--details
#80.41 sdetails
#90.40 sdetails
#100.40 sdetails

Code

# -*- coding: utf-8 -*-
"""
Created on Sat Sep 15 15:28:04 2018

@author: kiyakf1
"""

import itertools


def function():
    
    n = int(raw_input())
    pairs = []
    
    for i in range(n):
        pairs.append(raw_input().split(" "))

    x = list(raw_input())
    y = list(raw_input())
    
    def pairmap(string, pairs):
        pairmap = []
        for i in range(len(pairs)):
            pairmap.append([])
        
        for x in string:
            for i in range(len(pairs)):
                if x in pairs[i]:
                    pairmap[i].append(x)
        return pairmap
                    
                    
    for mapx,mapy in zip(pairmap(x,pairs),pairmap(y,pairs)):
        print(mapx)
        print(mapy)
        
        
        
function()

Test details

Test 1

Verdict:

input
5
a b
b c
c d
d e
...

correct output
YES

user output
['b', 'b', 'a']
['b', 'b', 'a']
['b', 'c', 'b', 'c']
['b', 'c', 'b', 'c']
['c', 'd', 'c']
...
Truncated

Test 2

Verdict:

input
2
a b
b c
acbbaca
cabbaac

correct output
YES

user output
['a', 'b', 'b', 'a', 'a']
['a', 'b', 'b', 'a', 'a']
['c', 'b', 'b', 'c']
['c', 'b', 'b', '

...
Truncated

Test 3

Verdict:

input
2
a b
b c
acbbaca
baccaab

correct output
NO

user output
['a', 'b', 'b', 'a', 'a']
['b', 'a', 'a', 'a', 'b']
['c', 'b', 'b', 'c']
['b', 'c', 'c', '

...
Truncated

Test 4

Verdict:

input
10
d c
e b
f y
h q
...

correct output
YES

user output
(empty)

Test 5

Verdict:

input
10
a i
a l
d a
g h
...

correct output
NO

user output
(empty)

Test 6

Verdict:

input
325
a b
a e
a f
a g
...

correct output
YES

user output
(empty)

Test 7

Verdict:

input
325
a c
a e
a g
a h
...

correct output
NO

user output
(empty)

Test 8

Verdict:

input
0
dlkinfmdyjaofxbccwhhbxzartqwdr...

correct output
YES

user output
(empty)

Test 9

Verdict:

input
0
bxisdrdpgcsnnvhnfgimivzqpqjwqc...

correct output
NO

user output
(empty)

Test 10

Verdict:

input
0
mrwduerojcguvxzmbomfsainvqehsl...

correct output
NO

user output
(empty)