UVA 12207-that is Your Queue

Source: Internet
Author: User

1#include <cstdio>2#include <iostream>3#include <deque>4 using namespacestd;5 6 intMain ()7 {8deque<Long>Cir;9     LongP, C, CAS =0;Ten  One      while(SCANF ("%ld%ld", &p, &c) &&P) A     { - cir.clear (); -          for(inti =1; I <= P && i <= +; i++)//1≤c≤1000 the Cir.push_back (i); -  -printf"Case %ld:\n", ++CAs); -  +          while(c--) -         { +             CharC; A GetChar (); atscanf"%c", &c); -  -             if(c = ='N') -             { -                 LongTEMPN =Cir.front (); - Cir.pop_front (); in Cir.push_back (TEMPN); -cout << TEMPN <<Endl; to}Else if(c = ='E') +             { -                 Longx; thescanf"%ld", &x); *                  for(deque<Long>::iterator it = Cir.begin (); It! = Cir.end (); ++it) $                     if(*it = =x)Panax Notoginseng                     { - Cir.erase (it); the                          Break; +                     } A Cir.push_front (x); the             } +         } -     } $     return 0; $}

Reason for time limit exceeded: And C, the number of commands to process (1≤c≤1000). Do not see this condition, not careful;

UVA 12207-that is Your Queue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.