---
# System prepended metadata

title: UVa 12207 - That is Your Queue
tags: [林基成-C++, UVA code, cpp, Awwwolf的刷題之路]

---

# UVa 12207 - That is Your Queue
## Online Judge
![](https://i.imgur.com/ZxxVy3M.png)

## 解題思路

## 解題中出現的bug
TLE:
1. 因為有時間的限制，賽入所有的數字會爆時間，所以一開始塞數字時取Ｐ和Ｃ的最小值塞入就可。
2. link-list的建立比較慢，建議用deque

Wrong Answer:
1. Case是大寫......
## Code
```cpp=
#include <iostream>
#include <deque>
using namespace std;
int main()
{
    int P, C, number;
    char ch;
    int counter = 1;
    while(cin>>P>>C && P!=0)
    {
        cout << "Case " << counter++ << ":\n";
        deque<int> li;
        for(int i=1;i<=min(P,C);i++)
            li.push_back(i);
        while(C--)
        {
            cin >> ch;
            if(ch=='N')
            {
                cout << li.front() << endl;
                li.push_back(li.front());
                li.pop_front();
            }
            else
            {
                cin >> number;
                li.push_front(number);
                for(deque<int>::iterator t1 =li.begin()+1;t1!=li.end();t1++)
                    if(*t1==number)
                    {
                        li.erase(t1);
                        break;
                    }
            }
        }
    }
    return 0;
}
```
###### tags: `UVA code` `cpp` `林基成-C++` `Awwwolf的刷題之路`