
| Contests | Virtual Contests | Problems | Submit | Runs Status | Rank List | Forum |
| Pripoae Teodor Anton | 6540. why restricted function? |
| 2008-11-17 04:07:24 | i get restricted function for the following source code: #include <cstdio> #include <cstdlib> #include <deque> #include <vector> using namespace std; deque<int> Q; vector<int> V; main(){ int i,n,m,x,pol,nr=0; char type; while (scanf("%d",&m)!=EOF){ scanf("%d",&n); Q.resize(0);nr=0; V.resize(n+1,0); while (n--){ scanf("%d",&x); V[x]=1; } pol=1;scanf("%c ",&type); while (type!='e'){ //printf("%c ",type); if (type=='a'){ scanf("%d",&x); if (Q.empty()) Q.push_back(x); else if (x<=Q.front()) Q.push_front(x); else if (x>=Q.back()) Q.push_back(x); } else if (type=='r'){ ++nr; if (!Q.empty()){ if (pol==1){ if (V[nr]) printf("%d\n",Q.front()); Q.pop_front(); } else{ if (V[nr]) printf("%d\n",Q.back()); Q.pop_back(); } } else printf("-1\n"); } else if (type=='p'){ scanf("%d",&x); pol=x; } scanf(" %c",&type); } printf("\n"); } } why? |
| 1 |