Program
Time limit2sMemory limit512 MB
Given a sequence of assignment and conditional assignment instructions starting from X=1, delete the fewest instructions so the final value is k, for every k.
- Level
Hard8 of 10
- Topics
- Graph, Shortest path, BFS, Implementation
- Solved
- No attempts yet
Problem
You are given a program that operates on an integer variable , which is initially equal to 1. The program consists of instructions of two types:
1 p() assigns the value to variable .2 p q(, ) assigns the value to variable only if the current value of is .
In one step, you can remove any single instruction from the program. You cannot reorder instructions or add new instructions. What is the minimum number of steps required to get a program that, after it runs, leaves variable with the value ? Solve this problem for each from 1 to .
Input
The first line of input contains a single integer (), the number of instructions in the program.
The next lines contain descriptions of instructions in the format described above.
Output
Output integers, where the -th integer is the minimum number of steps required to make the program assign the value to variable , or if it is impossible.