26 Apr Friday 17:00 Python Practice 21.04.23.
As the name implies, Googol Drive stores a vast amount of documents. So vast, in fact, that it would be impractical to manually search which documents are “shared with you” (and unfortunately, Googol does not support this operation yet). Given a list of N people numbered 1 to N who have an account on Googol Drive and M documents which are shared from person p to person q (1≤p,q≤N), figure out which documents are “shared with you” — that is, you have direct access to such a document as person q.
The first line of input contains two integers, N and M.
The next M pairs of lines will each contain pi and qi on the first line, and the document title on the second line. You can assume that no document title is over 30 characters long.
The last line of input will be one integer Y (1≤Y≤N), your number.
You are to output all documents that are “shared with you” (shared with person Y). The document names should each have their own line, and document names are case-sensitive. The order in which you output them in does not matter, as long the list is correct as a whole.
Sample Input 1 3 3 1 2 Road to Becoming a Philosopher 2 3 Hello, World 3 2 Untitled Document 2 Sample Output 1 Road to Becoming a Philosopher Untitled Document Explanation for Sample Input 1 Although all three documents are visible by you, you created the second one. Therefore, only two documents are "shared with you". Sample Input 2 4 3 1 2 Chapter 15 1 3 Chapter 16 1 4 Chapter 16.5 1 Sample Output 2
Recently, you have lost all sense of time, constantly forgetting what year it is. You assume this is due to that fact that you are in possession of the infamous Phone Microwave, which sends text messages to the past — for every second the microwave is set to, the message will go an hour back in time. In a desperate attempt to fix your internal temporal clock (which was ruined by confusing your past self with messages about the future), you decide to send one last message telling you not to acquire the suspicious-looking microwave in the first place. To do so, you need to write a program telling you what time your past self will receive the message, based on the current time and the microwave’s settings.
Given the date and setting on the microwave, figure out when your past self will receive the text. The microwave has a maximum time setting of 2 hours and you may assume that you always start between the years 2010 and 2011. The input will be given by the seconds and the time.
The first line of input contains an integer S, the Phone Microwave’s time setting, in seconds. This value will not exceed 7200 (2 hours).
The second line of input contains the current date, given in this format:
The year will be one of the years 2010 or 2011, the month will be a valid month from 01 to 12, and the day will be a valid day for that month.
The hour will be a valid hour from 00 to 23, and the minutes and seconds will each be a valid value ranging from 00 to 59.
You are to output the date when your past self receives the text, in the same format as the input as described in the previous section.
Sample Input 1 120 2010/07/28 13:00:00 Sample Output 1 2010/07/23 13:00:00 Explanation for Sample Input 1 The Phone Microwave is set to 120 seconds, which takes you back exactly 5 days. Sample Input 2 2 2011/01/01 01:23:45 Sample Output 2 2010/12/31 23:23:45 Explanation for Sample Input 2 The Phone Microwave takes you back 2 hours, which passes into the previous year.