【模板】deque实现单调队列
双端队列 deque 容器: 关于 deque 最常用的有这几个函数 : 都是成员函数 双端队列模板题: 【洛谷】P2952 [USACO09OPEN]牛线Cow Line 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<deque> 6 using namespace std; 7 8 int n, cnt; 9 deque< int > q; 10 11 int main() { 12 scanf( " %d\n " , & n); 13 char s[ 21 ]; 14 for ( int i= 1 ; i<=n; ++ i) { 15 gets(s); 16 if (s[ 0 ] == ' A ' ) 17 if (s[ 2 ] == ' L ' ) q.push_front(++ cnt); 18 else q.push_back(++ cnt); 19 if (s[ 0 ] == ' D ' ) { 20 int m = 0 , j = 1 ; 21 while (s[j]< ' 0 ' || s[j]> ' 9 ' ) ++ j; 22 while (s[j]>= ' 0 ' && s[j]<= ' 9 ' ) 23 m = (m