#P2366. Debugger's Watches
Debugger's Watches
Debugger's Watches
You are a member of the debugger development team. Your team has been assigned to implement a component called Watches (known in Chinese as "变量观察器"), which is used to monitor int type variables. Since the IDE is still in the testing phase, the team decided to start with only int
variables.
The Watches is expected to support three types of assignment statements:
n=1;
— Assign a constant to a variable. The constant will have at most $9$ digits.a=b;
— Assign the value of one variable to another. If the right-hand side variable has not been assigned a value yet, its default value is $0$.m=1+2;
— Assign the result of an expression that contains exactly two operands and a single plus operator. In such expressions, both operands (which can be either constants or variables) are guaranteed to lie between $1$ and $10^6$ if they are constants. If a variable operand has not been assigned a value, it is considered as $0$.
After processing all the statements, output the values of all variables that have been assigned (i.e. appeared on the left-hand side of an assignment) in lexicographical order of their identifiers. Each variable's value should be printed on a new line. It is guaranteed that no variable's value will exceed the maximum value for an int
.
inputFormat
The first line contains an integer N
representing the number of statements. The next N
lines each contain one statement. Each statement is one of the following forms:
variable=constant;
where the constant has at most 9 digits.variable=variable;
where the right-hand side variable's value is used (defaulting to 0 if not yet assigned).variable=operand1+operand2;
whereoperand1
andoperand2
are either constants (in the range from 1 to $10^6$) or variable names (defaulting to 0 if not assigned).
outputFormat
Output the values of all assigned variables in lexicographical (dictionary) order of their identifiers. Print each variable's value on a separate line.
sample
3
n=1;
a=n;
m=1+2;
1
3
1
</p>