http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=455
stack的應用,先讓一節車廂進來,比對看看出去的誰第一個出去,如果就是stack的TOP就POP掉,重複POP到出去的不是TOP為止,再讓下一節車廂進來。
最後要是stack有剩下元素沒POP,這個組合就是no,反之yes。
1 |
|
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=455
stack的應用,先讓一節車廂進來,比對看看出去的誰第一個出去,如果就是stack的TOP就POP掉,重複POP到出去的不是TOP為止,再讓下一節車廂進來。
最後要是stack有剩下元素沒POP,這個組合就是no,反之yes。
1 |
|