Company: Microsoft_13nov
Difficulty: medium
Session-Based Authentication System Problem Description Build a session-based authentication service that keeps user sessions alive for a fixed time-to-live. A token created or renewed at time t expires at t + time_to_live . The service answers three kinds of query: generate <token_id> <t> - create the token token_id at time t . If a token with that id already exists, it is replaced. renew <token_id> <t> - extend the token token_id at time t . The query is ignored when the token does not exist or has already expired. count <t> - report how many tokens are still unexpired at time t . Expiry is checked before any query at the same timestamp is processed. A token whose expiry time is exactly the current time has already expired: it cannot be renewed and it is not counted. The queries are given in non-decreasing order of their timestamp, and at least one of them is a count . Input Format The first line contains time_to_live . The second line contains q , the n