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 ...
随机推荐
- LeetCode Question Difficulty Distribution
参考链接:https://docs.google.com/spreadsheet/pub?key=0Aqt--%20wSNYfuxdGxQWVFsOGdVVWxQRlNUVXZTdEpOeEE& ...
- 超全!iOS 面试题汇总
之前看了很多面试题,感觉要不是不够就是过于冗余,于是我将网上的一些面试题进行了删减和重排,现在分享给大家.(题目来源于网络,侵删) 1. Object-c的类可以多重继承么?可以实现多个接口么?Cat ...
- 利用window.name+iframe跨域获取数据详解
详解 前文提到用jsonp的方式来跨域获取数据,本文为大家介绍下如何利用window.name+iframe跨域获取数据. 首先我们要简单了解下window.name和iframe的相关知识.ifra ...
- Ajax基础详解2
沐晴又来更新啦,话说我们上回讲到Ajax中open方法的第三个参数异步和同步的问题,今天呢,就来继续往下唠,先接着上回的代码 var oBtn = document.getElementById('b ...
- [转]JVM 内存初学 (堆(heap)、栈(stack)和方法区(method) )
这两天看了一下深入浅出JVM这本书,推荐给高级的java程序员去看,对你了解JAVA的底层和运行机制有比较大的帮助.废话不想讲了.入主题: 先了解具体的概念:JAVA的JVM的内存可分为3个区:堆(h ...
- OC基础--内存管理中的@property关键字以及其参数
在上一篇博客中整理的内存管理,管理类的代码量会感觉很大,而且如果对象多的话,感觉到代码有点冗余.下面就介绍Xcode中为我们自动生成内存管理代码的关键字@property 例如:在Person这个类中 ...
- Java 使用正则表达式
用正则表达式来处理掉内容中的特定字符,下面的代码为,去掉P标签中的属性width 设置.将P标签处理后在拼接成字符串 /** * 给 P 标签去掉width 样式设置 * @param content ...
- Hibernate-缓存-并发策略
当多个并发的事务同时访问持久化层的缓存中的相同数据时,会引起并发问题,必须采用必要的事务隔离措施. 在进程范围或集群范围的缓存,即第二级缓存,会出现并发问题.因此可以设定以下4种类型的并发访问策略,每 ...
- 【CodeForces 622A】Infinite Sequence
题意 一个序列是, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5....这样排的,求第n个是什么数字. 分析 第n个位置属于1到k,求出k,然后n-i*(i-1)/ ...
- BIEE 仪表盘的创建
1.新建仪表盘 选择共享文件夹里创建的表拖到仪表盘中 保存并运行 也可以新建更多仪表盘页 2.新建仪表盘提示 把提示和表都拖到仪表盘中 3.主从关系:第二张表的结果页面 ——>编辑视图——&g ...