본문 바로가기
알고리즘/소스코드

KOREATECH 1116: 짝궁 문자열

by cjw.git 2020. 12. 15.

Link : judge.koreatech.ac.kr/problem.php?id=1116


Python

더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from sys import stdin
 
testcase = int(stdin.readline().strip())
 
while testcase:
    x, y = list(map(str, stdin.readline().strip().split()))
    stack = []
    if len(x) == len(y):
        for idx in range(len(x)):
            if x[idx] != y[idx]:
                stack.append((x[idx], y[idx]))
        if len(stack) == 0:
            print('yes')
        elif len(stack) == 2:
            if stack[0][0== stack[1][1and stack[0][1== stack[1][0]:
                print('yes')
            else:
                print('no')
        else:
            print('no')
 
    else:
        print('no')
 
    testcase -= 1
 
cs

FeedBack

  1.  

 

 

 

cjw.git@gmail.com

댓글