# UVa 12207 - That is Your Queue ## Online Judge  ## 解題思路 ## 解題中出現的bug TLE: 1. 因為有時間的限制,賽入所有的數字會爆時間,所以一開始塞數字時取P和C的最小值塞入就可。 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的刷題之路`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up