The Great Pan

题目链接:

http://acm.hust.edu.cn/vjudge/contest/123554#problem/D

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 '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.

</big>

##Input
<big>
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.
</big> ##Output
<big>
For each test case print the number of ways to understand this statement, or "doge" if your answer is more than 105.
</big> ##Sample Input
<big>

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!
</big>

##Sample Output
<big>
4
4
doge
6
</big> <br/>
##题意:
<big>
计算给定的文字有多少种解释.
{} 中有 n 个 | 则有 n+1 种解释.
$$ 中每有 n个连续的空格则有 n+1 种解释.
不会出现上述两种形式的任何嵌套.
</big> <br/>
##题解:
<big>
由于不会出现嵌套,就比较简单了.
依次对每个出现的关键字符进行标记和计数即可.
注意:
数组要开大,否则TLE.
乘的过程有可能会爆int,要用longlong.
</big> <br/>
##代码:
``` cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#define LL long long
#define eps 1e-8
#define maxn 1010
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std; char str[5000000]; int main(int argc, char const *argv[])
{
//IN; int n;
while(scanf("%d", &n) != EOF)
{
getchar();
LL ans = 1;
int flag = 0;
LL cnt = 0;
bool flag1 = 0, flag2 = 0;
while(n--) {
gets(str);
int len = strlen(str);
if(flag) continue;
for(int i=0; i<len; i++) {
if(str[i] == '{') cnt = 0, flag1 = 1;
else if(str[i] == '}') {
flag1 = 0;
ans *= cnt + 1;
cnt = 0;
if(ans > 100000) {
flag = 1;
break;
}
}
else if(str[i] == '$') {
if(flag1) continue;
if(!flag2) cnt = 0, flag2 = 1;
else {
flag2 = 0;
ans *= cnt + 1;
cnt = 0;
if(ans > 100000) {
flag = 1;
break;
}
}
}
else if(str[i] == '|' && flag1) cnt++;
else if(str[i] == ' ' && flag2) {
cnt = 0;
while(i<len && str[i] == ' ') {
cnt++;
i++;
}
ans *= cnt + 1;
cnt = 0;
if(ans > 100000) {
flag = 1;
break;
}
i--;
}
}
} if(flag) printf("doge\n");
else printf("%lld\n", ans);
} return 0;
}

HDU 4891 The Great Pan (模拟)的更多相关文章

  1. HDU 4891 The Great Pan (字符串处理)

    题目链接:HDU 4891 The Great Pan 求一串字符有多少种不同的意思,当中关心'{','}'之间的'|'. 和'$','$'之间的空格,连续N个空格算N+1种. AC代码: #incl ...

  2. 2014多校第三场1005 || HDU 4891 The Great Pan(模拟)

    题目链接 题意 : 给你n行字符串,问你有多少种理解方式.有两大类的理解 (1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D. (2)$blah blah$,在$$这两个符号中 ...

  3. HDU 4891 The Great Pan (题意题+模拟)

    题意:给定一个文章,问你有多少种读法,计算方法有两种,如果在$中,如果有多个空格就算n+1,如果是一个就算2的次方,如果在{}中, 那么就是把每个空格数乘起来. 析:直接模拟,每次计算一行,注意上一行 ...

  4. HDU 4891 The Great Pan

    模拟题. #include<map> #include<set> #include<ctime> #include<cmath> #include< ...

  5. 2014联合三所学校 (HDU 4888 HDU 4891 HDU 4893)

    HDU 4891 The Great Pan 注册标题  他怎么说,你怎么样  需要注意的是乘法时,它会爆炸int 代码: #include<iostream> #include<c ...

  6. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  7. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  8. hdu 4891 模拟

    题意:       给你一个串,问你有几种意思,有两个规则 (1) { }  答案乘以  ({}之间"|"的个数 + 1)  (2)  &&   答案乘以  (&a ...

  9. HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

随机推荐

  1. POJ 2455 - Secret Milking Machine

    原题地址:http://poj.org/problem?id=2455 题目大意:给出一个N个点的无向图,中间有P条边,要求找出从1到n的T条通路,满足它们之间没有公共边,并使得这些通路中经过的最长的 ...

  2. bzoj1064

    很巧妙的题 首先有几种情况 1. 有环 2.两点间有多条路径 3.其他 3.显然最简单,最小是3,最大是每个弱联通块中最长链 2.显然,两点间两条路径的差是答案的倍数 1.出现环,那答案一定是其约数, ...

  3. UVa 1262 (第k字典序) Password

    题意: 给出两个6行5列的字母矩阵,一个密码满足:密码的第i个字母在两个字母矩阵的第i列均出现. 然后找出字典序为k的密码,如果不存在输出NO 分析: 我们先统计分别在每一列均在两个矩阵出现的字母,然 ...

  4. ASP.NET缓存OutputCache和Response.Cache之C#后台设置

    一.ASPX页面缓存页面缓存的使用方法非常的简单,只需要在aspx页的顶部加一句声明<%@ OutputCache Duration="60" VaryByParam=&qu ...

  5. SJ9012: IE6 IE7 不支持 JSON 对象

    标准参考 JSON 是一种数据交换格式,RFC 4627 对 JSON 进行了详细描述. 根据 ECMA-262(ECMAScript)第 5 版中描述,JSON 是一个包含了函数 parse 和 s ...

  6. Android实现全屏显示的方法

    一种是在xml文件中设置相应属性,另一种是用代码实现. 1.在AndroidManifest.xml的配置文件里面的<activity>标签添加属性: android:theme=&quo ...

  7. 【unity3D】鼠标控制camera的移动、放大(俯视浏览效果、LOL摄像机移动效果)

    在Unity开发中,用鼠标滚轮来实现摄像机的视野范围,鼠标左键拖拉控制摄像机的移动,代码如下: 1.俯视浏览效果 using UnityEngine; using System.Collections ...

  8. 【经典DFS】NYOJ-1058-部分和问题

    [题目链接:NYOJ-1058] 看到题目难度是2,所以想也没想,直接循环比较...结果果然... 是错的. #include<cstdio> #include<cstring> ...

  9. Python easy_install

    系统中有高版本的Python, 直接pip3 install ipcalc安装,都是装到高版本的Python 系统默认的Python是2.7.6,现在想装到默认版本中,可以使用easy_install ...

  10. Linux Kernel 4.8分支第4个候选版本发布

    导读 今天,大神Linus Torvalds宣布了Linux 4.8分支的第四个候选版本,该候选版本在提供常规驱动更新.架构改善和部分KVM调整之外最大的新功能就是修复了英特尔Skylake电源管理B ...