티스토리 뷰
👩🏻💻 문제
✍🏻 풀이
🎨 Go
// https://www.acmicpc.net/problem/17219
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, m int
fmt.Fscanln(reader, &n, &m)
var passwordMap = map[string]string{}
for i := 0; i < n; i++ {
var input string
input, _ = reader.ReadString('\n')
input = strings.ReplaceAll(input, "\n", "")
inputs := strings.Split(input, " ")
passwordMap[inputs[0]] = inputs[1]
}
for i := 0; i < m; i++ {
var site string
fmt.Fscanln(reader, &site)
fmt.Fprintln(writer, passwordMap[site])
}
}
🎨 Python3
# https://www.acmicpc.net/problem/17219
import sys
if __name__ == "__main__":
n, m = list(map(int, sys.stdin.readline().split()))
passwords = {}
for i in range(n):
site, password = sys.stdin.readline().rstrip().split(" ")
passwords[site] = password
for i in range(m):
site = sys.stdin.readline().rstrip()
print(passwords[site])
728x90
'dev > algorithm' 카테고리의 다른 글
BOJ / 11656번 / 접미사 배열 [Go][Python3] (0) | 2021.02.07 |
---|---|
BOJ / 10799번 / 쇠막대기 [Go][Python3] (0) | 2021.02.06 |
BOJ / 1302번 / 베스트셀러 [Go][Python3] (0) | 2021.02.04 |
BOJ / 3986번 / 좋은 단어 [Go][Python3] (0) | 2021.02.03 |
BOJ / 1620번 / 나는야 포켓몬 마스터 이다솜 [Go][Python3] (0) | 2021.02.02 |
댓글