Advertisement
Saleh127

UVA 12207

Oct 7th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll p,c,t=1;
  11. while(cin>>p>>c &&p&&c )
  12. {
  13. list<ll>q;
  14. list<ll>::iterator it;
  15. for(ll i=1;i<=min(p,c);i++)
  16. {
  17. q.push_back(i);
  18. }
  19. cout<<"Case "<<t++<<":\n";
  20. while(c--)
  21. {
  22. char z;
  23. cin>>z;
  24. if(z=='N')
  25. {
  26. cout<<q.front()<<endl;
  27. q.push_back(q.front());
  28. q.pop_front();
  29. }
  30. else
  31. {
  32. ll s;
  33. cin>>s;
  34. it=find(q.begin(),q.end(),s);
  35. if(it!=q.end()) q.erase(it);
  36. q.push_front(s);
  37. }
  38. }
  39. }
  40.  
  41.  
  42. return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement