goosegoose.DRAM
article thumbnail

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

 

7785번: 회사에 있는 사람

첫째 줄에 로그에 기록된 출입 기록의 수 n이 주어진다. (2 ≤ n ≤ 106) 다음 n개의 줄에는 출입 기록이 순서대로 주어지며, 각 사람의 이름이 주어지고 "enter"나 "leave"가 주어진다. "enter"인 경우는

www.acmicpc.net

import sys

hash = {}

num = int(sys.stdin.readline())
for _ in range(num):
    name, situation = map(str, sys.stdin.readline().split())
    if situation == 'leave':
        del hash[name]
    else:
        hash[name] = situation
re = sorted(hash.keys(), reverse=True)

for key in re:
    print(key)

 

 

 

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

 

1351번: 무한 수열

첫째 줄에 3개의 정수 N, P, Q가 주어진다.

www.acmicpc.net

import sys
from collections import defaultdict

def find_num(n):
    if hash[n] != 0:
        return hash[n]
    else:
        hash[n] = find_num(n//P) + find_num(n//Q)
    return hash[n]

N,Q,P = map(int, sys.stdin.readline().split())
hash = defaultdict(int)
hash[0] = 1

print(find_num(N))

 

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

 

1620번: 나는야 포켓몬 마스터 이다솜

첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? 모르면

www.acmicpc.net

import sys

epoch, q = map(int, sys.stdin.readline().split())
re = {}
for i in range(epoch):
    name = sys.stdin.readline()
    re[i+1] = name[:-1]

rever = {v:k for k,v in re.items()}
for i in range(q):
    an = sys.stdin.readline()
    if 48 <= ord(an[0]) <= 57:
        print(re[int(an)])
    else:
        print(rever[str(an[:-1])])
profile

goosegoose.DRAM

@goosesong

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!