POJ1068双端队列模拟
来源:互联网 发布:java中集合map 编辑:程序博客网 时间:2024/04/30 07:47
//题意:P代表当前右括号位置前面有多少个左括号//W代表右括号位置从与它匹配的位置到该位置有多少个右括号#include <iostream>#include <stdio.h>#include <string.h>#include <queue>using namespace std;int n;int P[25];int W[25];int main(){int T;scanf("%d",&T);while(T--){deque<int>que;scanf("%d",&n);for (int i=0;i<n;++i)scanf("%d",&P[i]);int c = 1;for(int i=0;i<n;++i){if (i==0){for (int j=0;j<P[i];++j)//前面的左括号数目{que.push_back(c++);}}else{for (int j=0;j<P[i]-P[i-1];++j)//前面的左括号数目{que.push_back(c++);}}//加入该右括号//同时将一个左括号移出int k = que.back();que.pop_back();W[i] = (c - k + 1)/2;c++;}for (int i=0;i<n-1;++i)printf("%d ",W[i]);printf("%d\n",W[n-1]);}return 0;}
0 0
- POJ1068双端队列模拟
- poj1068 模拟
- poj1068 模拟
- POJ1068(模拟)
- POJ1068模拟
- POJ1068《Parencodings》方法:模拟
- POJ1068 Parencodings(模拟)
- POJ1068 Parencodings(模拟)
- POJ1068 Parencodings 模拟题
- poj1068模拟法
- POJ1068 Parencodings(模拟)
- poj1068 Parencodings 【模拟】
- poj1068 Parencodings 模拟 栈
- POJ1068(ACM括号模拟)
- POJ1068 Parencodings (模拟)
- Parencodings(POJ1068 模拟)
- Parencodings(poj1068简单模拟)
- poj1068 Parencodings 模拟水题
- 黑马程序员——OC语言日志——NSMutableString和NSMutableArray 的介绍及使用
- 二:Windows100个系统命令
- javascript基本使用 9 ------call,apply
- Dom
- Log4Net 的使用
- POJ1068双端队列模拟
- Android开发历程之一:Activity组件-Activity生命周期
- 局部变量和成员变量的区别
- linux内核参数注释与优化
- 第一发博客
- Git使用小结(一)
- 三:Windows常用命令实例
- Android学习【10】PreferenceFragment偏好设置(二)
- JVM调优总结 -Xms -Xmx -Xmn -Xss