affiche juste le code, pas d'explications !
- User
System: affiche juste le code, pas d'explications ! User: Tu es un développeur python3 expérimenté, et tu dois concevoir un programme en python (avec des commentaires en français, sans utiliser de librairies externes, sans
if __name__=="__main__":, avec type hints, et en privilégiant les algorythmes a complexité constante (O(1)) et/ou complexité linéaire (O(n))). Le programme va recevoir les données en entrée sur la stdin, et doit répondre sur la stdout. Fabrique moi un programme python qui résout le problème (énoncé en markdown) suivant :Open doors
Tomorrow's the big day: your exhibition opens to the public.
But when you go to make the final preparations, you realize that there has been a very big problem with the layout of your exhibition space: some rooms are completely inaccessible!
You call an emergency meeting of the crisis committee, and the problem must be solved by tomorrow morning. A complete inventory of the rooms is carried out, as well as the doors and walkways allowing access from one room to another.
The most urgent task is to find out which rooms are inaccessible to visitors, no matter which route they take to try to access them. Can you save your team and draw up a list of blocked rooms as quickly as possible?
Visitors enter the exhibition center through room numbered 1, while the other rooms are numbered from 2 to N.
Data
Input
Line 1: two integers N and M, respectively the number of rooms and the number of doors.
M next lines: two integers representing the room numbers linked by a door.
Output
If all rooms are accessible, display only the "OK" string.
Otherwise, display in ascending order the numbers of all rooms not accessible from room 1, one integer per line.
Constraints
There are a maximum of 1000 rooms and 1000 doors in the exhibition space.
Doors can be opened in any direction.
Remember that rooms are numbered from 1 upwards.
Example 1
Input:
plaintext7 10 1 4 2 3 1 2 7 5 4 7 6 2 3 5 4 2 7 3 6 1[image: Illustration of example 1] open
The answer is :
plaintextOKHere, this network of 7 rooms is correctly configured: visitors can access all the rooms starting from room 1.
- Assistantpython