:3
Everything is barely weeks. Everything is days. We have minutes to live.
- about me
- Github: @r1bb1t-h0l3
Everything is barely weeks. Everything is days. We have minutes to live.
Posted
This week I finally hit 50 solved problems on DMOJ! Problem number 51 for me was Rue’s Rings
This was a good opportunity for me to try out the map python method which I had found out about recently, but hadn’t had the opportunity to implement. I also used the “really huge number” approach which I had learned about from “Learn to code by solving problems” by Daiel Zingaro.
Anyway, this took me a few tries to get because of formatting issues and such, but I got there in the end. Here’s my solution code:
for dataset in range(10):
routes = []
number_of_routes = int(input())
for _ in range(number_of_routes):
route_info = list(map(int, input().split()))
route_id = route_info[0]
min_r = min(route_info[2:])
routes.append((route_id, min_r))
min_diameter = 70001
for i in range(len(routes)):
if routes[i][1] < min_diameter:
min_diameter = routes[i][1]
route_number = []
for i in range(len(routes)):
if min_diameter == routes[i][1]:
route_number.append((routes[i][0]))
route_number.sort()
str_sorted_routes = list(map(str, route_number))
answer = '{' + ','.join(str_sorted_routes)+'}'
print(f"{min_diameter} {answer}")
Author
ribbit
Categories
coding challenge