Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-09-29] wooyeol #270 #294

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions BOJ/싸이버개강총회/wooyeol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
싸이버개강총회
https://www.acmicpc.net/problem/19583

풀이시간
11:20 ~ 12:10 (50분)

문제 조건
(00:00 ≤ S < E < Q ≤ 23:59)
0 < 채팅 기록 < 10만

시간 복잡도 :
strptime은 N 길이의 문자열의 길이를 파싱할 때 O(N) - O(5)
O(100,000)

접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 해시 테이블

시간을 datetime 객체로 변환 후 조건의 시간들과 비교하여
출석부에 삽입 혹은 제거 연산을 시행하고 그 횟수를 남긴다.
"""
import sys
from datetime import datetime

input = sys.stdin.readline

S,E,Q = input().split()

# S,E,Q를 Datatime 객체로 변환
S = datetime.strptime(S, "%H:%M")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datetime.strptime() 함수를 lambda 함수를 통해 map으로 변환하기

E = datetime.strptime(E, "%H:%M")
Q = datetime.strptime(Q, "%H:%M")

# 출석부 이름을 저장할 집합 생성
name_table = set()

# 출석 인정된 사람 수
count = 0

while True:
log = input().split()

# log가 입력되지 않으면 break
if not log:
break

time = datetime.strptime(log[0], "%H:%M")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우열님 log[0]과 log[1]을 채팅 시간이랑 닉네임으로 명시적으로 써주면 좋을 것 같아요~!!
고생하셨습니다 👍👍


# 개강총회 시작전에 채팅을 남겼다면 출석부에 이름 추가
if time <= S:
name_table.add(log[1])

# 개강 총회가 끝나고 스트리밍 종료 전에 채팅을 남겼다면 출석부에서 이름 확인 후 제거 및 출석 인정
elif E <= time <= Q:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

54번째 라인과 55번째 라인의 조건문을 합치기

if log[1] in name_table:
name_table.remove(log[1])
count += 1

print(count)