2014杭电多校联合第三场 1005
2014-07-29 20:44
218 查看
http://acm.hdu.edu.cn/showproblem.php?pid=4891
Problem Description
As a programming contest addict, Waybl is always happy to take part in various competitive programming contests. One day, he was competing at a regional contest of Inventing Crappy Problems Contest(ICPC). He tried really hard to solve a "geometry" task without
success.
After the contest, he found that the problem statement is ambiguous! He immediately complained to jury. But problem setter, the Great Pan, told him "There are only four possibilities, why don't you just try all of them and get Accepted?".
Waybl was really shocked. It is the first time he learned that enumerating problem statement is as useful as trying to solve some ternary search problem by enumerating a subset of possible angle!
Three years later, while chatting with Ceybl, Waybl was told that some problem "setters" (yeah, other than the Great Pan) could even change the whole problem 30 minutes before the contest end! He was again shocked.
Now, for a given problem statement, Waybl wants to know how many ways there are to understand it.
A problem statement contains only newlines and printable ASCII characters (32 ≤ their ASCII code ≤ 127) except '{', '}', '|' and '$'.
Waybl has already marked all ambiguity in the following two formats:
1.{A|B|C|D|...} indicates this part could be understand as A or B or C or D or ....
2.$blah blah$ indicates this part is printed in proportional fonts, it is impossible to determine how many space characters there are.
Note that A, B, C, D won't be duplicate, but could be empty. (indicate evil problem setters addedclarified it later.)
Also note that N consecutive spaces lead to N+1 different ways of understanding, not 2N ways.
It is impossible to escape from "$$" and "{}" markups even with newlines. There won't be nested markups, i.e. something like "${A|B}$" or "{$A$|B}" or "{{A|B}|C}" is prohibited. All markups will be properly matched.
Input
Input contains several test cases, please process till EOF.
For each test case, the first line contains an integer n, indicating the line count of this statement. Next n lines is the problem statement.
1 ≤ n ≤ 1000, size of the input file will not exceed 1024KB.
Output
For each test case print the number of ways to understand this statement, or "doge" if your answer is more than 105.
Sample Input
9
I'll shoot the magic arrow several
times on the ground, and of course
the arrow will leave some holes
on the ground. When you connect
three holes with three line segments,
you may get a triangle.
{|It is hole! Common sense!|
No Response, Read Problem
Statement|don't you know what a triangle is?}
1
Case $1: = >$
5
$/*This is my code printed in
proportional font, isn't it cool?*/
printf("Definitely it is cooooooool \
%d\n",4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4
* 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4);$
2
$Two space$ and {blue|
red} color!
Sample Output
4
4
doge
6
输入包含 $ $ 及 {a|b|c} 这样的标记的文本,对于 {a|b|c} 这样的标记,答案乘里面 | 的数量 +1。对于 $ $ 这样的标记,在内部每遇到 n 个连续的空格就把答案乘 n + 1。如果答案不超过 100000,输出答案,否则输出 doge。
总之,题目说什么,就怎么做就可以了。
Problem Description
As a programming contest addict, Waybl is always happy to take part in various competitive programming contests. One day, he was competing at a regional contest of Inventing Crappy Problems Contest(ICPC). He tried really hard to solve a "geometry" task without
success.
After the contest, he found that the problem statement is ambiguous! He immediately complained to jury. But problem setter, the Great Pan, told him "There are only four possibilities, why don't you just try all of them and get Accepted?".
Waybl was really shocked. It is the first time he learned that enumerating problem statement is as useful as trying to solve some ternary search problem by enumerating a subset of possible angle!
Three years later, while chatting with Ceybl, Waybl was told that some problem "setters" (yeah, other than the Great Pan) could even change the whole problem 30 minutes before the contest end! He was again shocked.
Now, for a given problem statement, Waybl wants to know how many ways there are to understand it.
A problem statement contains only newlines and printable ASCII characters (32 ≤ their ASCII code ≤ 127) except '{', '}', '|' and '$'.
Waybl has already marked all ambiguity in the following two formats:
1.{A|B|C|D|...} indicates this part could be understand as A or B or C or D or ....
2.$blah blah$ indicates this part is printed in proportional fonts, it is impossible to determine how many space characters there are.
Note that A, B, C, D won't be duplicate, but could be empty. (indicate evil problem setters addedclarified it later.)
Also note that N consecutive spaces lead to N+1 different ways of understanding, not 2N ways.
It is impossible to escape from "$$" and "{}" markups even with newlines. There won't be nested markups, i.e. something like "${A|B}$" or "{$A$|B}" or "{{A|B}|C}" is prohibited. All markups will be properly matched.
Input
Input contains several test cases, please process till EOF.
For each test case, the first line contains an integer n, indicating the line count of this statement. Next n lines is the problem statement.
1 ≤ n ≤ 1000, size of the input file will not exceed 1024KB.
Output
For each test case print the number of ways to understand this statement, or "doge" if your answer is more than 105.
Sample Input
9
I'll shoot the magic arrow several
times on the ground, and of course
the arrow will leave some holes
on the ground. When you connect
three holes with three line segments,
you may get a triangle.
{|It is hole! Common sense!|
No Response, Read Problem
Statement|don't you know what a triangle is?}
1
Case $1: = >$
5
$/*This is my code printed in
proportional font, isn't it cool?*/
printf("Definitely it is cooooooool \
%d\n",4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4
* 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4);$
2
$Two space$ and {blue|
red} color!
Sample Output
4
4
doge
6
输入包含 $ $ 及 {a|b|c} 这样的标记的文本,对于 {a|b|c} 这样的标记,答案乘里面 | 的数量 +1。对于 $ $ 这样的标记,在内部每遇到 n 个连续的空格就把答案乘 n + 1。如果答案不超过 100000,输出答案,否则输出 doge。
总之,题目说什么,就怎么做就可以了。
#include <stdio.h> #include <string.h> #include <iostream> using namespace std; char a[10000004]; int n; int main() { while(~scanf("%d%*c",&n)) { int x=0,y=0,z=0; long long cnt,ans=1; int flag=0; for(int p=0;p<n;p++) { gets(a); if(flag==1) continue; int m=strlen(a); for(int i=0;i<m;i++) { if(a[i]=='{'&&x==0) { x=1; cnt=1; } else if(a[i]=='|'&&x==1) cnt++; else if(a[i]=='}'&&x==1) { x=0; ans*=cnt; if(ans>100000) { flag=1; break; } } else if(a[i]=='$'&&y==0) y=1; else if(a[i]=='$'&&y==1) y=0; else if(a[i]==' '&&y==1) { long long count=1; while(a[i]==' ') count++,i++; ans*=count; if(ans>100000) { flag=1; break; } i--; } } } if(ans>100000) printf("doge\n"); else printf("%I64d\n",ans); } return 0; }
相关文章推荐
- 2014杭电多校联合第三场The Great Pan模拟题
- 2014杭电多校联合第一场Task(贪心+STL使用)
- 2017多校联合第三场 1005题 hdu 6060 RXD and dividing (超详细!!!)构造
- 2014杭电多校联合第一场Jump费用流(最小K路径覆盖)
- 2014多校联合-第三场
- HDU 4893 Wow! Such Sequence!(2014年多校联合 第三场 G)(线段树)
- HDU 4876 ZCC loves cards (2014多校联合训练第二场1005) 解题报告(暴力+剪枝)
- 2014多校联合-第三场
- hdu 4891 The Great Pan 2014多校联合第三场
- HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场
- hdoj 4939 2014多校联合7 1005
- HDU 5762 Teacher Bo (鸽笼原理) 2016杭电多校联合第三场
- 2017杭电多校第三场1005 RXD and dividing(最大化k个斯坦纳树分块的最大权值和)HDU6060
- HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
- hdu4882ZCC Loves Codefires【贪心】2014多校联合
- 2014多校联合第9场1011题||hdu 4970 树状数组
- 杭电2014
- 2014多校联合第9场1006||hdu 4965 矩阵乘法和快速幂
- 【noip2014】联合权值
- 杭电oj2014 c++