Search
Duplicate
๐Ÿฅˆ

์•”๊ธฐ์™•

์ฃผ์ฐจ
๋ฌธ์ œ๋ฒˆํ˜ธ
2776
์–ธ์–ด
Python
ํ‹ฐ์–ด
์‹ค๋ฒ„
์œ ํ˜•
์ด๋ถ„ํƒ์ƒ‰
nj_Blog
O
nj_์ƒํƒœ
์™„๋ฃŒ
์ดํ•ด๋„
ํ’€์ด
์‚ฌ๋žŒ
์ดํ•ด๋„ 2
13 more properties

๋ฌธ์ œ๋งํฌ

https://www.acmicpc.net/problem/2776

Code

์ œ์ถœ ๋‚ ์งœ

@4/23/2021

๋ฉ”๋ชจ๋ฆฌ

336536 KB

์‹œ๊ฐ„

1368 ms
์ด๋ถ„ํƒ์ƒ‰ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  set ์œผ๋กœ ํ’ˆ!
โ†’ set ์œผ๋กœ ์•ˆํ•˜๊ณ  list๋กœ ํ’€๋ฉด ์‹œ๊ฐ„์ดˆ๊ณผ ๋œธ
T = int(input()) for _ in range(T): n = int(input()) note1 = set(map(int, input().split())) m = int(input()) note2 = list(map(int, input().split())) for num in note2: if num in note1: print(1) else: print(0)
Python
๋ณต์‚ฌ

์ œ์ถœ ๋‚ ์งœ

@4/23/2021

๋ฉ”๋ชจ๋ฆฌ

345464 KB

์‹œ๊ฐ„

2036 ms
์ด๋ถ„ํƒ์ƒ‰์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ œ ํ’€๊ธฐ!
โ†’ ๊ทผ๋ฐ ์‹œ๊ฐ„์ด ๋”.. ์˜ค๋ž˜ ๊ฑธ๋ฆผ....?
def binary_search(start, end, num): global note1 while start <= end: mid = (start + end) // 2 if note1[mid] == num: return 1 elif note1[mid] < num: start = mid + 1 else: end = mid - 1 return 0 T = int(input()) for _ in range(T): n = int(input()) note1 = list(map(int, input().split())) m = int(input()) note2 = list(map(int, input().split())) note1.sort() for num in note2: print(binary_search(0, n-1, num))
Python
๋ณต์‚ฌ