POJ 1068 解题报告
来源:互联网 发布:apache官网下载教程 编辑:程序博客网 时间:2024/06/16 22:27
这道题就是按照题意模拟做出来的,主要是数据量很小。通过输入的p可以确定括号序列,然后按照次序注意处理,左括号压栈,右括号入栈,同时统计w值。
1068Accepted248K16MSC++1314B/* ID: thestor1 LANG: C++ TASK: poj1068 */#include <iostream>#include <fstream>#include <cmath>#include <cstdio>#include <cstring>#include <limits>#include <string>#include <vector>#include <list>#include <set>#include <map>#include <queue>#include <stack>#include <algorithm>#include <cassert>using namespace std;const int MAXN = 100;int main(){std::ios::sync_with_stdio(false);std::vector<int> parentheses(MAXN, 0);int T;cin >> T;for (int t = 0; t < T; ++t){int n;cin >> n;int k = 0, p0 = 0;for (int i = 0; i < n; ++i){int p;cin >> p;for (int j = 0; j < p - p0; ++j){parentheses[k] = 1;k++;}parentheses[k] = 0;k++;p0 = p;}n = 2 * n;// cout << "parentheses:";// for (int i = 0; i < n; ++i)// {// cout << parentheses[i];// }// cout << endl;stack<int> st;for (int i = 0; i < n; ++i){// left parentheseif (parentheses[i]){st.push(i);}else{int left = st.top();st.pop();int cnt = 1;for (int j = left + 1; j < i; ++j){if (parentheses[j] == 0){cnt++;}}cout << cnt << " ";}}cout << endl;}return 0; }
0 0
- POJ 1068解题报告
- POJ-1068解题报告
- POJ 1068 解题报告
- poj 1068解题报告
- POJ 1068 解题报告
- poj数百篇解题报告
- poj 1141解题报告
- poj 1001解题报告
- poj 1011 解题报告
- poj 1087 解题报告
- poj 2153解题报告
- poj 2051解题报告
- POJ 1167 解题报告
- poj 1026 解题报告
- POJ 1077 解题报告
- POJ 1042 解题报告
- POJ 1095 解题报告
- POJ 1159解题报告
- 最大子列和问题
- 在Eclipse中搭建quick-cocos2d-x的lua开发环境
- ZendStudio导入一个已有的网站
- Android.mk file syntax specification
- Console命令详解,让调试js代码变得更简单
- POJ 1068 解题报告
- excel宏·终极版
- Hive on Spark运行环境搭建
- 鸟哥私房菜实践(6)- NFS
- PriorityBlockingQueue优先级规则
- Access denied for user 'www-data'@'localhost' (using password: NO)
- visual studio 中打开自带的sql server express
- 回溯法扫盲帖
- UITableView个人学习记录