#K7081. Browser History Simulator
Browser History Simulator
Browser History Simulator
This problem simulates a simplified web browser history management system. You are given a sequence of operations that manipulate the browser history. Initially, the browser starts at its homepage, which is homepage
. The operations are in one of the following forms:
visit <url>
: Visit a new URL. This clears any forward history.back <steps>
: Go back by a given number of steps. You cannot go back beyond the homepage.current
: Output the current URL that the browser is showing.
Your task is to simulate these operations. Let $n$ be the number of operations. For each current
operation, output the current URL. All formulas are written in LaTeX format; for example, the number of operations is given by $n$.
inputFormat
The input is read from stdin
and has the following format:
- An integer
n
representing the number of operations. n
lines each containing one operation. Each operation is one of:visit <url>
back <steps>
current
outputFormat
For each current
operation encountered, output the current URL on a new line on stdout
.
5
visit google.com
visit youtube.com
back 1
current
current
google.com
google.com
</p>