#K47942. Institution Log Management
Institution Log Management
Institution Log Management
This problem requires you to simulate a log management system for an institution. The system tracks visitor entries and exits, and can answer queries regarding the current status of a visitor and the total number of people inside.
You are given an integer \(n\) which represents the number of log events. Each event is given as a string and can be one of the following types:
"name enter"
: the visitor with the given name enters the institution. If the visitor is already inside, this event is ignored."name exit"
: the visitor with the given name exits the institution. If the visitor is not inside, this event is ignored."status name"
: query the status of the visitor with the given name. Print inside if the visitor is currently inside the institution, otherwise print outside."total"
: query the total counts of visitors currently inside. Print the integer count.
Your program should process these events in order and output results for each query (i.e. for events starting with status
or total
). The outputs must be printed on separate lines in the order the queries appear.
Note: The formulas and variable representations use LaTeX format where necessary, such as \(n\) for the number of events.
inputFormat
The input is read from stdin and has the following format:
<integer n> <event 1> <event 2> ... <event n>
Where n
is the number of log entries and queries. Each of the next n lines contains a string representing an event or query.
outputFormat
The output is written to stdout. For every query (i.e., events that are either status
queries or total
queries), output the corresponding result on a new line. For a status
query, print inside
or outside
. For a total
query, print the total number of visitors currently inside.
8
Alice enter
Bob enter
status Alice
status Bob
Alice exit
total
status Alice
status Bob
inside
inside
1
outside
inside
</p>