개발자 톡

연습문제 톡 [21년 재직자 대회 예선] 회의실 예약

회의실 예약 반례 부탁드립니다 ,,,

등록일
2023-05-28 20:34:29
조회수
430
작성자
ironee1

import sys

n,m = map(int,input().split())

room_list = []

info_list = []

time_list = [[1]*19 for _ in range(n)]

result_list = [[] for _ in range(n)]

for i in range(n):
    room_list.append(input())

room_list = sorted(room_list)

for i in range(m):
    info_list.append(input().split())



# ['grandeur','avante','sonata']
# [['sonata','14','16'],['grandeur','11','12'],['avante','15','18'],['sonata','10','11'],['avante','9','12'],['grandeur','16','18'],['avante','12','15']]

for i in range(m):
    for j in range(n):
        if info_list[i][0] == room_list[j]:
            start = int(info_list[i][1])
            end = int(info_list[i][2])
            for k in range(start,end):
                time_list[j][k] = 0

#[[1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,0,1],
#[1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1],
#[1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1]]
# print(time_list)

first_index = -1
end_index = -1

for i in range(n):
    for j in range(9,18):
        if first_index == -1 and time_list[i][j] == 1:
            first_index = j
            time_list[i][j] = 0
        elif first_index != -1 and end_index == -1 and (j+1 == 18 or time_list[i][j] == 0):
            if j+1 == 18:
                end_index = j+1
            else:   
                end_index = j
            time_list[i][j] = 0
            # print(i,first_index,end_index)
            result_list[i].append((first_index,end_index))
            first_index = -1
            end_index = -1

#[[(9,11),(12,16)],[],[(9,10),(11,14),(16,18)]]
# print(result_list)

for i in range(n):
    print(f"Room {room_list[i]}:")
    if len(result_list[i]) == 0:
        print("Not available")
    else:
        print(f"{len(result_list[i])} available:")
        for j in result_list[i]:
            if j[0] < 10:
                start_time = f"0{j[0]}"
            else:
                start_time = str(j[0])
            if j[1] < 10:
                end_time = f"0{f[1]}"
            else:
                end_time = str(j[1])
            print(f"{start_time}-{end_time}")
    if i != n-1:
        print("-----")


ㅇ회의실 예약 반례 아시는 분 계실까요,, ㅠㅠㅠ

#[21년_재직자_대회_예선]_회의실_예약
#python

이 카테고리의 톡 더보기