http://vjudge.net/contest/view.action?cid=51327#problem/D
Description
Input
Output
Sample Input
input |
---|
(We) [are] {blind}, if (we) [could not see] {creation of this clone army} |
output |
Blind we are, if creation of this clone army we could not see |
input |
{Truly wonderful} (the mind of a child) [is] |
output |
Truly wonderful the mind of a child is |
#include <iostream>
#include <cstring>
#include <cstdio> using namespace std; char str[];
char ob[],sub[],veb[];
int o,sb,ve;
int i,j;
int len,star; int main()
{
while(gets(str))
{
star=;
o=sb=ve=;
len=strlen(str);
for(i=;i<len;i++)
{
if(str[i]=='(')
{
i++;
while(i<len&&str[i]!=')')
{
sub[sb++]=str[i++];
}
} else if(str[i]=='{')
{
i++;
while(i<len&&str[i]!='}')
{
ob[o++]=str[i++];
}
}
else if(str[i]=='[')
{
i++;
while(i<len&&str[i]!=']')
{
veb[ve++]=str[i++];
}
}
else
{
if(str[i]==',')
{
for(j=;j<o;j++)
{
if(star)
{
if(ob[]>='a'&&ob[]<='z')
{
putchar(ob[]-);
}
else putchar(ob[]);
star=;
continue;
}
putchar(ob[j]);
}
putchar(' ');
o=;
for(j=;j<sb;j++)
{
if(j==&&sub[]<='Z'&&sub[]>='A')
putchar(sub[j]+);
else putchar(sub[j]);
}
putchar(' ');
sb=;
for(j=;j<ve;j++)
{
if(j==&&veb[]<='Z'&&veb[]>='A')
putchar(veb[j]+);
else putchar(veb[j]);
}
ve=;
putchar(',');
i++;
while(str[i]!='{'&&str[i]!='('&&str[i]!='[')
{
if(i<len){
putchar(str[i]);
i++;
}
else
{
break;
}
}
i--;
}
}
}
if(o||sb||ve)
{
for(j=;j<o;j++)
{
if(star)
{
if(ob[]>='a'&&ob[]<='z')
{
putchar(ob[]-);
}
else putchar(ob[]);
star=;
continue;
}
putchar(ob[j]);
}
putchar(' ');
for(j=;j<sb;j++)
{
if(j==&&sub[]<='Z'&&sub[]>='A')
putchar(sub[j]+);
else putchar(sub[j]);
}
putchar(' ');
for(j=;j<ve;j++)
{
if(j==&&veb[]<='Z'&&veb[]>='A')
putchar(veb[j]+);
else putchar(veb[j]);
}
}
putchar('\n');
}
return ;
}
putchar(); 字符输出 与cout没有其他差别
eg:putchar('a'-32)==A
cout<<'a'-32<<endl; ==65
The Great Pan
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1003 Accepted Submission(s): 352
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.
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.
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!
4
doge
6
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring> using namespace std;
#define LL long long char str1[];
char str[]; int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
memset(str,'/0',sizeof(str));
LL ans = ;
LL tans=;
int len = ;
getchar();
for(int i = ; i <= n; i ++)
{
gets(str1);
int len1 = strlen(str1);
for(int j = ; j < len1 ; j++)
str[j+len] = str1[j];
len = len + len1;
} int is = ;
int t = ;
int ok = ; for(int i = ; i < len ; i ++)
{
if(ok == )
break;
if(is)
{
if(str[i] == ' ')
{
t++;
if(str[i+] != ' ')
{
tans *=(t+);
t = ;
}
}
else if(str[i] == '$')
{
is = ;
ans = tans * ans;
tans = ;
}
if(tans > )
{
ok = ;
}
}
else
{
if(str[i] == '{')
{
int t = ;
int j ;
for(j = i +; ; j ++)
{
if(str[j] == '}')
break;
if(str[j] == '|')
t ++ ;
}
i = j;
ans *= t ;
if(ans > )
{
ok = ;
}
}
else
{
if(str[i] == '$')
is = ;
}
}
}
if(ok )
printf("doge\n");
else
printf("%I64d\n",ans);
}
return ;
}