Skip to content

Commit 048d33c

Browse files
committed
[BOJ] ZOAC 3/ 실버 5 / 40분
https://www.acmicpc.net/problem/20436
1 parent a09ccab commit 048d33c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def coordinate(char):
2+
for i in range(3):
3+
if char in keyboard[i]:
4+
j = keyboard[i].index(char)
5+
return (i, j)
6+
7+
8+
# 쿼터식 키보드 이중 배열
9+
keyboard = [['z', 'x', 'c', 'v', 'b', 'n', 'm'], ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'],
10+
['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p']]
11+
12+
l, r = map(str, input().split())
13+
string = str(input())
14+
# 입력된 문자 좌표로 바꾸기
15+
now = [coordinate(l), coordinate(r)]
16+
word = [coordinate(i) for i in string]
17+
18+
sum = 0
19+
for char in word:
20+
if (char[0] == 0 and char[1] >= 4) or char[1] >= 5: # 오른손으로 입력하는 경우
21+
sum += abs(now[1][0] - char[0]) + abs(now[1][1] - char[1]) + 1
22+
now[1] = char
23+
else: # 왼손으로 입력하는 경우
24+
sum += abs(now[0][0] - char[0]) + abs(now[0][1] - char[1]) + 1
25+
now[0] = char
26+
print(sum)

0 commit comments

Comments
 (0)