Parencodings - poj 1068】的更多相关文章

  Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22764   Accepted: 13344 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is…
题目地址:http://poj.org/problem?id=1068 /* 题意:给出每个右括号前的左括号总数(P序列),输出每对括号里的(包括自身)右括号总数(W序列) 模拟题:无算法,s数组把左括号记为-1,右括号记为1,然后对于每个右括号,numl记录之前的左括号 numr记录之前的右括号,sum累加s[i]的值,当sum == 0,并且s[i]是左括号(一对括号)结束,记录b[]记录numl的值即为答案 我当时题目没读懂,浪费很长时间.另外,可以用vector存储括号,还原字符串本来的…
题目链接 大概题意就是告诉你有个n个小括号,每一个")"左边有多少个"("都告诉你了,然后让你求出每一对括号之间有多少对括号(包含自己本身). 思路: 我先计算每个")"左边有多少个"("要匹配,然后每遇到一个")",然后向前寻找第一个可以匹配的"(",找到后将其数量减一,这样的话在寻找的过程中经过了几个")"就表示这对括号里面有多少括号. //poj 1068 //…
链接: http://poj.org/problem?id=1068 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#problem/B Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17044   Accepted: 10199 Description Let S = s1 s2...s2n be a well-forme…
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; int ind[45]; bool used[45]; int r[21]; int l[21]; int len,n,llen; int w[21]; int main(){ int t; scanf("%d",&t); while(t--){ memset(used,0,siz…
题目链接:http://poj.org/problem?id=1068 思路分析:对栈的模拟,将栈中元素视为广义表,如 (((()()()))),可以看做 LS =< a1, a2..., a12 >,对于可以配对的序列,如 <a4, a5>看做一个元素,其 W 值为1: 同理,<a6, a7>为一个元素,其W值为1,< a3, a4, a5, a6, a7, a8, a9, a10 >看做一个元素, 其W值为 <a4, a5> 与 <a6…
                                                                                                Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19550   Accepted: 11804 Description Let S = s1 s2...s2n be a well-formed string…
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem? id=1068 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways:  q By an integer sequ…
Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24932   Accepted: 14695 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn…
Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19352   Accepted: 11675 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways:  q By an integer sequence P = p1 p2...pn…
Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22849   Accepted: 13394 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways:  q By an integer sequence P = p1 p2...pn…
进入每个' )  '多少前' (  ', 我们力求在每' ) '多少前' )  ', 我的方法是最原始的图还原出来,去寻找')'. 用. . #include<stdio.h> #include<string.h> int y[505],t[505]; char s[505]; int main() { int a,b,i,j,u; scanf("%d",&a); while(a--) { memset(y,0,sizeof(y)); memset(t,…
Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right parenthesis in S (P-sequence). q B…
http://poj.org/problem?id=1068 这道题是一道模拟的题目 题目大意呢,p代表前面的'('的个数,而w代表这个括号所包括的括号的个数: 给你p,要你求w: 解题思路: 首先,你肯定要把p所对应的那一个括号序列还原出来,当然,你也没必要说用字符把()表示出来,完全就可以用0和1分别代替左括号与右括号 其次,你就应该找出哪两个括号是相匹配的.比如说(((()()()))),p为456666,第一个)所匹配的为第4个左括号,第二个所匹配的为第5个左括号,第三个所匹配的为第6个…
POJ的题目都是英文的,所以,,,还是直接贴代码吧 #include<stdio.h> int main(){ int x,y,z; int n,nm,max; scanf("%d",&n); while(n--){ int num[60]={0}; scanf("%d",&nm); for(x = 0;x < nm; x++){ scanf( "%d",&y); num[ y+x+1 ]=1; } fo…
Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23545   Accepted: 13802 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn…
这次的题目是著名的模拟(水逼)专题 题目难度都不大,思维也不深,就是一个字——烦 同时很多题目都有很多坑点 1608 题意是告诉你一个只有()的字符串(且匹配正确),每个)的左边有几个(,让你求每一对括号中包含了几对括号. 思路很水,模拟出原字符串再开个栈做一次就行了. CODE #include<cstdio> using namespace std; ; int t,n,s[N],stack[N],i,j,x,last,del,top; inline void read(int &…
OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递推. 构造法.(POJ 3295) 模拟法.(POJ 1068,POJ 2632,POJ 1573,POJ 2993,POJ 2996) 二…
著名题单,最初来源不详.直接来源:http://blog.csdn.net/a1dark/article/details/11714009 OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递…
题目传送门 本题知识点:模拟 这是一道恐怖的括号题.题意稍微理解以下还是可以的. 我们针对样例来理解一下 S.P.W 到底是什么意思: S:( ( ( ( ) ( ) ( ) ) ) ) P: \(P_1\) 为 4 :是因为在第一个 ) (数组第4位)前面有4个 ( \(P_2\) 为 5 :是因为在第二个 ) (数组第6位)前面有5个 ( \(P_3\) 为 6 :是因为在第三个 ) (数组第8位)前面有6个 ( (后面 \(P_4\) \(P_5\) \(P_6\) 情况跟 \(P_3\)…
POJ 1068,题目链接http://poj.org/problem?id=1068 题意: 对于给出给出的原括号串S,对应两种数字密码串P.W: S         (((()()()))) P-sequence      4 5 6666   (Pi表示第i个右括号前面有多少个左括号) W-sequence     1 1 1456    (Wi表示第i个右括号对应它前面的第几个左括号) 要求给出P串,求W. 思路: 1. 模拟类题型.将输入的P串先装换为S串,再由S串得到W串. 2. 左…
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1936 Description You have devised a new encryption technique which enc…
1.Link: http://poj.org/problem?id=1068 http://bailian.openjudge.cn/practice/1068 2.Content: Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20077   Accepted: 12122 Description Let S = s1 s2...s2n be a well-formed string of p…
POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom /ZOJ 1291 MPI Maelstrom (最短路径) Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shar…
Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22757   Accepted: 13337 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn…
POJ 排序的思想就是根据选取范围的题目的totalSubmittedNumber和totalAcceptedNumber计算一个avgAcceptRate. 每一道题都有一个value,value = acceptedNumber / avgAcceptRate + submittedNumber. 这里用到avgAcceptedRate的原因是考虑到通过的数量站的权重可能比提交的数量占更大的权重,所以给acceptedNumber乘上了一个因子. 当然计算value还有别的方法,比如POJ上…
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  1024   Calendar Game       简单题  1027   Human Gene Functions   简单题  1037   Gridland            简单题  1052   Algernon s Noxious Emissions 简单题  1409   Commun…
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive…
此文来自北京邮电大学ACM-ICPC集训队 此50题在本博客均有代码,可以在左侧的搜索框中搜索题号查看代码. 以下是原文: POJ推荐50题1.标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉.2.标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目.3.列表中大约有70个题目.大家选做其中的50道,且每类题目有最低数量限制.4.这里不少题目在BUPT ACM FTP上面都有代码,请大家合理利用资源.5.50个题目要…
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01K以上. 短:1147.1163.1922.2211.2215.2229.2232.2234.2242.2245.2262.2301.2309.2313.2334.2346.2348.2350.2352.2381.2405.2406: 中短:1014.1281.1618.1928.1961.2054…