Hdu 4891 The Great Pan

The Great Pan

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 154    Accepted Submission(s): 52


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 2 N 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
 

虽然是道签到题,还是忍不住要来吐槽一下。

题意:有两种符号代表两种状态,{}与||配套,表示有多少种情况。$$中间空格数有多少种情况。$ $一个空格有两种情况0,1,依次类推。问一个字符串总共有多少情况,大于1e5输出doge.末尾算连续。&u u u&这中间有两个空格算2*2.坑爹的地方在于结果要是__int64类型,因为中间乘法运算有可能超过了int范围。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
using namespace std;
#define LL __int64
char s[1005][100000];
int l[1005];
int main()
{
	int n,i,f;
	while (~scanf("%d",&n))
	{
		f=0;
		getchar();
		LL L=0;
		for (i=1;i<=n;i++)
		{
			gets(s[i]);
			l[i]=strlen(s[i]);
			L+=l[i];
		}
		int j=0,a=0,b=0,t=0,pos=0,k; //两个状态 
		i=1;
		LL ans=1;
		while (pos<L)
		{
			if (a==0 && b==0)
			{
				if (s[i][j]=='{') {a=1;k=1;}
				if (s[i][j]=='$') b=1;
				j++;
				pos++;
			}
			else if (a==1)
			{
				if (s[i][j]=='|') k++;
				if (s[i][j]=='}')
				{
					ans*=k;
					a=0;
				}
				j++;pos++;
			}
			else if (b==1)
			{
				if (s[i][j]=='$')
				{
					b=0;
					j++;
					pos++;
					if (j==l[i])
					{
						i++;
						j=0;
					}
					continue;
				}
				k=0;
				while (s[i][j]==' ')
				{
					k++;
					j++;
					pos++;
					if (j==l[i])
					{
						i++;
						j=0;
					}
				}
				if (k!=0)
					ans*=(k+1);
				else
				{
					j++;pos++;
				}
			}
			if (j==l[i])
			{
				i++;
				j=0;
			}
			if (ans>100000)
			{
				f=1;
				break;
			}
		}
		if (f==1) puts("doge");
		else cout<<ans<<endl;
	}
	return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值