uva 12207 - That is Your Queue

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uva 12207 - That is Your Queue相关的知识,希望对你有一定的参考价值。

 

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <deque>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     deque<long> cir;
 9     long P, C, cas = 0;
10 
11     while(scanf("%ld%ld", &P, &C) && P)
12     {
13         cir.clear();
14         for (int i = 1; i <= P && i <= 1000; i++)   // 1 ≤ C ≤ 1000
15             cir.push_back(i);
16 
17         printf("Case %ld:\n", ++cas);
18 
19         while(C--)
20         {
21             char c;
22             getchar();
23             scanf("%c", &c);
24 
25             if(c == N)
26             {
27                 long tempN = cir.front();
28                 cir.pop_front();
29                 cir.push_back(tempN);
30                 cout << tempN << endl;
31             }else if(c == E)
32             {
33                 long x;
34                 scanf("%ld", &x);
35                 for(deque<long>::iterator it = cir.begin(); it != cir.end(); ++ it)
36                     if(*it == x)
37                     {
38                         cir.erase(it);
39                         break;
40                     }
41                 cir.push_front(x);
42             }
43         }
44     }
45     return 0;
46 }

Time limit exceeded的原因:and C, the number of commands to process (1 ≤ C ≤ 1000).没看到这一条件,不仔细;

以上是关于uva 12207 - That is Your Queue的主要内容,如果未能解决你的问题,请参考以下文章

HiltkotlinIllegalStateException: Unsupported metadata version. Check that your Kotlin version is

Metro server (run ‘react-native start‘) or that your bundle ‘index.android.bundle‘ is packaged corre

Metro server (run ‘react-native start‘) or that your bundle ‘index.android.bundle‘ is packaged corre

Metro server (run ‘react-native start‘) or that your bundle ‘index.android.bundle‘ is packaged corre

Metro server (run ‘react-native start‘) or that your bundle ‘index.android.bundle‘ is packaged corre

错误-Android-OpenCV-It seems that your device does not support camera(or it is locked)