ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
var cards = map[int]int{}
for i := 0; i < n; i++ {
var input int
if i == n-1 {
fmt.Fscanln(reader, &input)
} else {
fmt.Fscan(reader, &input)
}
cards[input]++
}
var m int
fmt.Fscanln(reader, &m)
for i := 0; i < m; i++ {
var num int
fmt.Fscanf(reader, "%d ", &num)
fmt.Fprintf(writer, "%s ", hasCard(cards, num))
}
}
func hasCard(cards map[int]int, num int) string {
if cards[num] != 0 {
return "1"
}
return "0"
}
๐จ Python3
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
cards = {}
cards_inputs = list(map(int, sys.stdin.readline().split()))
for i in cards_inputs:
cards[i] = 1
m = int(sys.stdin.readline())
num_inputs = list(map(int, sys.stdin.readline().split()))
results = []
for i, v in enumerate(num_inputs):
if cards.get(v):
print(1, end=' ')
else:
print(0, end=' ')
if i == m-1:
print()
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 11279๋ฒ / ์ต๋ ํ [Go][Python3] (0) | 2020.11.28 |
---|---|
BOJ / 1764๋ฒ / ๋ฃ๋ณด์ก [Go][Python3] (0) | 2020.11.27 |
BOJ / 2110๋ฒ / ๊ณต์ ๊ธฐ ์ค์น [Go][Python3] (0) | 2020.11.25 |
BOJ / 20207๋ฒ / ๋ฌ๋ ฅ [Go] (0) | 2020.11.24 |
BOJ / 20206๋ฒ / ํธ์์ด๊ฐ ๊ธธ์ ๊ฑด๋๊ฐ ์ด์ [Go] (0) | 2020.11.23 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- MongoDB
- baekjoon
- ์ด๋ถํ์
- ๋ถํ ์ ๋ณต
- ๋ธ๋ฃจํธํฌ์ค
- ์๊ฐ๊ต์ฒด
- ์คํ
- ๋ฐฑ์ค
- BFS
- go
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋ชฝ๊ณ ๋๋น
- Macbook pro 2012 mid 13
- ํด์๋งต
- ์๊ณ ๋ฆฌ์ฆ
- dp
- ballet
- dfs
- ๋งฅ๋ถํ๋ก
- java
- Algorithm
- ์๋ฐ
- ํ
- python3
- AWS
- ๋ฐ๋
- BOJ
- Golang
- ํ๋ก์ด๋์์ฌ
- ๋งฅ๋ถ
- Total
- Today
- Yesterday