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