HDU4891_The Great Pan_字符串水题
2014多校第五题,当时题面上的10^5写成105,我们大家都wa了几发,改正后我和一血就差几秒…不能忍
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4891
The Great PanTime 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
|
大意是说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_字符串水题的更多相关文章
- 1222: FJ的字符串 [水题]
1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1 = “A” A2 = ...
- 1001 字符串“水”题(二进制,map,哈希)
1001: 字符串“水”题 时间限制: 1 Sec 内存限制: 128 MB提交: 210 解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- HDU ACM 1073 Online Judge ->字符串水题
分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...
- 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 ...
- 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 ...
- uva 10252 - Common Permutation 字符串水题
题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...
- hdu1106 字符串水题strtok()&&strchr()&&sscanf()+atoi()使用
字符串的题目 用库函数往往能大大简化代码量 以hdu1106为例 函数介绍 strtok() 原型: char *strtok(char s[], const char *delim); 功能: 分解 ...
- codeforces 112APetya and Strings(字符串水题)
A. Petya and Strings 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input ...
随机推荐
- Activiti系列:是否可以让某些流程的信息写到历史表,而另外一些不写?
一.起因 打算使用activiti的定时启动事件来定时启动流程,然后再在该流程中针对每个用户启动另外一个流程实例来计算每个用户的实时账单,系统的用户数一般是1000~2000(此处假设是200 ...
- 【逆向怎么玩】 动态调试一款牛逼C++ IDE实录
声明 本篇只从逆向兴趣出发,研究其程序运行原理. CLion程序版权为jetBrains所有. 注册码授权为jetBrains及其付费用户所有. 不会释出任何完整的源代码. 涉及能直接推算出注册码的地 ...
- 『开源』仿SQLServer山寨一个 跨数据库客户端
002 Laura.SqlForever项目简单介绍 相关文章 <『练手』001 Laura.SqlForever架构基础(Laura.XtraFramework 的变迁)> <『练 ...
- 免费的SSL证书,免费为微信小程序搭建https
StartSSL 也免费提供了一个证书(纯英文) 申请地址:https://www.startssl.com/Account?r=L1ZhbGlkYXRl 阿里云免费提供的证书 https://com ...
- [BZOJ1406][AHOI2007]密码箱(数论)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1406 分析: (x+1)(x-1)是n的倍数 于是可以把n分解成n=ab,则a为(x+ ...
- 【BZOJ1008】【HNOI2008】越狱(数学排列组合题)
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 3140 Solved: 1317[Submit][Status] ...
- [USACO2004][poj1985]Cow Marathon(2次bfs求树的直径)
http://poj.org/problem?id=1985 题意:就是给你一颗树,求树的直径(即问哪两点之间的距离最长) 分析: 1.树形dp:只要考虑根节点和子节点的关系就可以了 2.两次bfs: ...
- AngularJS开发指南9:AngularJS作用域的详解
AngularJS作用域是一个指向应用模型的对象.它是表达式的执行环境.作用域有层次结构,这个层次和相应的DOM几乎是一样的.作用域能监控表达式和传递事件. 作用域的特点 作用域提供APIs($wat ...
- 开课选课系统APP基本功能实现
队员:031302511 031302505 效果图如下: 上述功能分析: 功能分析:我们考虑到手机自带的SQLite会被清理软件清理掉数据,这样就没有实际用处.所以我们就自己搭建服务器 ...
- 并行程序设计模式--Master-Worker模式
简介 Master-Worker模式是常用的并行设计模式.它的核心思想是,系统有两个进程协议工作:Master进程和Worker进程.Master进程负责接收和分配任务,Worker进程负责处理子任务 ...