We will find a way, we always have.

-interstellar

Problem Solving/๋ฐฑ์ค€

[๋ฐฑ์ค€] 9536๋ฒˆ: ์—ฌ์šฐ๋Š” ์–ด๋–ป๊ฒŒ ์šธ์ง€? - ํŒŒ์ด์ฌ

Redddy 2022. 5. 7. 15:09

๐ŸŽถ ์„œ๋ก 

์–ด๋ ธ์„ ๋•Œ ์œ ํ–‰ํ–ˆ๋˜ ๋…ธ๋ž˜ ์™“๋”๋ฝž์Ž„์—์„œ ์˜๊ฐ์„ ์–ป์€ ๋ฌธ์ œ๊ฐ™๋‹คใ…‹ใ…‹ใ…‹
์˜ค๋žœ๋งŒ์— ๋‹ค์‹œ ๋…ธ๋ž˜ ๋“ค์–ด๋ณด๋‹ˆ ์—ฌ์ „ํžˆ ์žฌ๋ฐŒ๊ณ  ํž™ํ•œ ๋…ธ๋ž˜๋‹ค. ์•ฝ๊ฐ„ ๋‹ค๋ฅธ์˜๋ฏธ๋กœ ์ฒœ์žฌ๋ž„๊นŒ

 

๐Ÿงฉ๋ฌธ์ œ ํ•ด์„

์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์ค‘์—์„œ ๋ช‡๊ฐœ์˜ ๋‹จ์–ด๋“ค์„ ์ œ๊ฑฐํ•˜๋ฉด ๋˜๋Š” ๋‹จ์ˆœ ํŒŒ์‹ฑ๋ฌธ์ œ์˜€๋‹ค.

 

๐Ÿ“– ํ’€์ด

1. ๋…น์Œ๋œ ์†Œ๋ฆฌ๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ฐ›๋Š”๋‹ค.
2. ๋‹ค๋ฅธ ๋™๋ฌผ๋“ค์˜ ์šธ์Œ์†Œ๋ฆฌ๋ฅผ ano_ani ๋ผ๋Š” set์— ์ €์žฅํ•œ๋‹ค.
3. ๋…น์Œ๋œ ์†Œ๋ฆฌ์ค‘ ano_ani์— ์žˆ์œผ๋ฉด ์—ฌ์šฐ์˜ ์†Œ๋ฆฌ๊ฐ€ ์•„๋‹ˆ๊ณ  ๋‹ค๋ฅธ ๋™๋ฌผ์˜ ์†Œ๋ฆฌ๋ž€ ๊ฒƒ์„ ์˜๋ฏธํ•˜๋‹ˆ ๊ทธ๊ฒƒ์„ ์ œ์™ธํ•˜๊ณ  ์ถœ๋ ฅํ•œ๋‹ค.

 

๐Ÿ’ป ์ฝ”๋“œ

import sys
input = sys.stdin.readline
ano_ani = set()
t = int(input().rstrip())
for i in range(t):
    record = list(map(str, input().rstrip().split()))
    for j in range(100):
        animal = list(map(str, input().rstrip().split()))
        if animal[0] == "what":
            break
        else:
            ano_ani.add(animal[2])
    for k in record:
        if k not in ano_ani:
            print(k, end=" ")

 

๐Ÿ”— ๋ฌธ์ œ๋งํฌ : ์—ฌ์šฐ๋Š” ์–ด๋–ป๊ฒŒ ์šธ์ง€?

 

9536๋ฒˆ: ์—ฌ์šฐ๋Š” ์–ด๋–ป๊ฒŒ ์šธ์ง€?

๊ฐ ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋งˆ๋‹ค ์—ฌ์šฐ์˜ ์šธ์Œ์†Œ๋ฆฌ๋ฅผ ํ•œ ์ค„์”ฉ, ๋…น์Œ๋œ ์ˆœ์„œ๋Œ€๋กœ ์ถœ๋ ฅํ•œ๋‹ค. ์—ฌ์šฐ์˜ ์šธ์Œ์†Œ๋ฆฌ๊ฐ€ ๋…น์Œ๋˜์–ด ์žˆ์Œ์ด ๋ณด์žฅ๋œ๋‹ค. (์•Œ๋ ค์ง„ ๊ฒƒ๊ณผ๋Š” ๋‹ฌ๋ฆฌ, ์—ฌ์šฐ๋Š” ๋ชจ์Šค ๋ถ€ํ˜ธ๋กœ ์˜์‚ฌ์†Œํ†ตํ•˜์ง€ ์•Š๋Š”๋‹ค.)

www.acmicpc.net

 

์—ฌ์šฐ