// Data Structure -- stack <br/> // open a number first and mark the number as the couple number <br/> // start from 1 ~ 2n is pushed into the stack one by one, and the couple array is called to check whether it can be merged with the top element of the stack <br/> // if it can be merged, remove from the stack top <br/> // to the end. If the stack top is empty, <br/> # include <iostream> <br/> # include <stack> <br/> # include <cstring> <br/> using namespace STD; <br/> int couple [200010]; <br/> int main () <br/>{< br/> int n, l, R; <br/> while (scanf ("% d", & N) <br/>{< br/> memset (couple,-1, sizeof (couple); <br/> stack <int> S; <br/> for (INT I = 0; I <n; ++ I) <br/>{< br/> scanf ("% d", & L, & R); <br/> couple [l] = R; <br/> couple [R] = L; <br/>}< br/> for (INT I = 1; I <= 2 * n; ++ I) <br/>{< br/> If (S. empty () s. push (I); <br/> else if (couple [I] = S. top () s. pop (); <br/>}< br/> If (S. empty () printf ("Yes/N"); <br/> elseprintf ("No/N"); <br/>}< br/> return 0; <br/>}