Flippy MEX
Time limit2sMemory limit512 MB
After each double-sided card is added, count how many distinct mex values are possible over all ways to flip the cards placed so far.
- Level
Medium7 of 10
- Topics
- Array, Greedy, Implementation
- Solved
- No attempts yet
Problem
is the function that returns the smallest non-negative integer missing from a given sequence. Junseo made a game with cards for Siwoo, who likes .
The rules are as follows. The steps run from to in order.
- In step , Junseo places card on the table. The front and back of the card have non-negative integers and written on them.
- For each of the ways to flip the cards on the table, Siwoo treats the numbers facing up as a sequence and computes its . Then Siwoo states how many distinct values are possible.
- Junseo checks Siwoo's answer and moves on to step .
Help Siwoo find the answer Siwoo should state at each step.
Input
The first line contains the number of cards .
From the second line onward, each of the next lines contains two integers and , separated by a space, which give the information for the -th card.
Output
On the -th line, print the answer Siwoo should state in step .