This repository was archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
[2023-09-29] wooyeol #270 #294
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datetime.strptime() 함수를 lambda 함수를 통해 map으로 변환하기