2014多校第五题,当时题面上的10^5写成105,我们大家都wa了几发,改正后我和一血就差几秒…不能忍

题目:http://acm.hdu.edu.cn/showproblem.php?pid=4891

The Great Pan

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

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
 
Author
Fudan University
 
Source
 
Recommend
We have carefully selected several similar problems for you:  4896 4895 4894 4893 4892

大意是说acm有时题意不清,给出一段题,n行中,有一些{A|B|C|D}和一些$biu biu biu$,其中ABCD是4种题意,$ $之间的空格数目不明,本来是连续的5个空格就有6种可能性(0,1,2,3,4,5),求这一段题的可能性数。

其实就是数{}的竖线、数$$中的连续空格,一个个字符处理就行,特别水,我都怕。

代码:

 #include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define ll __int64
#define RE freopen("1.in","r",stdin)
const ll dogenum=;
int main() {
//RE;
ll n,i,j,k,ans,cnt,koha;
char c,s[];
ll flag;
while(scanf("%lld",&n)!=EOF) {
do {
scanf("%c",&c);
} while(c!='\n');
flag=;
ans=;
for(i=; i<n; i++) {
//cout<<'['<<i<<']'<<endl;
if(ans==-) {
gets(s);
continue;
}
while(scanf("%c",&c)!=EOF && c!='\n') {
if(flag==) {
if(c=='{') flag=,cnt=;
else if(c=='$') flag=,koha=;
} else if(flag==) {
if(c=='|') cnt++;
else if(c=='}') {
if(cnt>dogenum) {
ans=-;
gets(s);
break;
} else ans*=cnt;
if(ans>dogenum) {
ans=-;
gets(s);
break;
}
flag=;
}
} else if(flag==) {
if(c==' ') koha++;
else {
if(c=='$') flag=;
if(koha>) {
if(koha+>dogenum) {
ans=-;
gets(s);
break;
}
ans*=koha+;
// cout<<'('<<ans<<')';
if(ans>dogenum) {
ans=-;
gets(s);
break;
}
koha=;
}
}
}
}
}
if(ans==-) printf("doge\n");
else printf("%lld\n",ans);
}
return ;
}

HDU4891_The Great Pan_字符串水题的更多相关文章

  1. 1222: FJ的字符串 [水题]

    1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1  =  “A” A2  =   ...

  2. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串“水”题 时间限制: 1 Sec  内存限制: 128 MB提交: 210  解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...

  3. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  4. HDU ACM 1073 Online Judge -&gt;字符串水题

    分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...

  5. Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题

    B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...

  6. Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题

    A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  7. uva 10252 - Common Permutation 字符串水题

    题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...

  8. hdu1106 字符串水题strtok()&&strchr()&&sscanf()+atoi()使用

    字符串的题目 用库函数往往能大大简化代码量 以hdu1106为例 函数介绍 strtok() 原型: char *strtok(char s[], const char *delim); 功能: 分解 ...

  9. codeforces 112APetya and Strings(字符串水题)

    A. Petya and Strings 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. 第十章实践——系统级I/O代码运行

    第十章实践——系统级I/O代码运行 实验代码清单如下: 1. cp1——复制一个文件到另一个文件中(两个已经存在的文件) 复制前: 执行后结果 2. setecho.echostate——改变.显示输 ...

  2. UISwitch和UIActivity的使用

    - (void)viewDidLoad{    [super viewDidLoad];    //创建一个开关控件,苹果给它固定的size(79*27),frame更改size无效    //继承于 ...

  3. sqlite3的使用(iOS嵌入式关系数据库)

    1>添加sqlite3动态库:libsqlite3.dylib,CoreGraphics.framework,UIKit.framework,Foundation.framework 2> ...

  4. ionic 项目笔记

    最近公司在用ionic 做 微站,项目中难免遇到一些问题.总结如下: 1.       改了Slidebox 动态绑定图片时,页面会显示一片空白,改变窗口大小的时候,图片就出来了,说明动态绑定图片时, ...

  5. Git.Framework 框架随手记--ORM新增操作

    本篇主要记录具体如何新增数据,废话不多说,开始进入正文. 一. 生成工程结构 上一篇已经说到了如何生成工程结构,这里在累述一次. 1. 新建项目总体结构 使用VS新建项目结构,分层结构可以随意.我们使 ...

  6. 06.C#泛型约束和高级泛型(三章3.3-3.4)

    吃午饭前继上篇泛型再写一篇关于泛型的文章,虽然总是被博客园移出首页,文章不精确实是大问题啊,会再接再厉的.进入正题. 先来说下泛型约束.当我们在使用泛型的时候通常会希望使用泛型实参时,参数能具备某一些 ...

  7. Set up gradle HiveMind

    HiveMind is a comprehensive ERP application for service organizations. It includes a project managem ...

  8. nginx 出现413 Request Entity Too Large问题的解决方法

    nginx 出现413 Request Entity Too Large问题的解决方法 使用php上传图片(大小1.9M),出现 nginx: 413 Request Entity Too Large ...

  9. 每天一个linux命令(23): chown命令

    chown将指定文件的拥有者改为指定的用户或组,用户可以是用户名或者用户ID:组可以是组名或者组ID:文件是以空格分开的要改变权限的文件列表,支持通配符.系统管理员经常使用chown命令,在将文件拷贝 ...

  10. 小心as"陷阱"(c#)

    有一种情况,使用as编译时没错,运行时也没错,但是结果错了. object a=1; string b=a as String; 由于a是objecy类型,是引用类型,所以可以用as转换,但是实际上b ...