zoukankan      html  css  js  c++  java
  • uva 12207

     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:
    ", ++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).没看到这一条件,不仔细;

  • 相关阅读:
    过滤字符串
    sql业务分割
    如何用core自动创建model,与数据库连接
    记录日志
    easyui获取选中行上一行的数据
    获取天气插件代码
    粘包问题
    网络编程
    异常处理
    isinstance和issubclass、元类、反射
  • 原文地址:https://www.cnblogs.com/aze-003/p/5157000.html
Copyright © 2011-2022 走看看