zoukankan      html  css  js  c++  java
  • HDU 4891— The Great Pan


    The Great Pan

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


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

    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 ",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
     
    #include<stdio.h>
    #include<string.h>
    int main()
    {
        int n, len, i, j, flag1, flag2;
        char s[1000001];
       long long cnt1, cnt2, sum1, sum2, ans;
    
        while(~scanf("%d", &n))
        {
            memset(s, '', sizeof(s));
            cnt1 = 1;
            cnt2 = 1;
            sum1 = 0;
            sum2 = 0;
            ans=1;
            flag1=flag2=0;
    
          for(i=0; i<=n; i++){
              gets(s+strlen(s));
           }
    
            len = strlen(s);
            for(i=0; i<len; i++)
            {
                if(s[i]=='{')
                {
                    flag1=1;
                }
                if(flag1)
                    if(s[i]=='|')
                        cnt1++;
                if(s[i]=='}')
                    {
                       ans*= cnt1;
                       cnt1=1;
                       flag1=0;
                    }
                if(flag2%2==1 && s[i]!=' ' && s[i-1]==' ')
                {
                    ans*=cnt2;
                    cnt2=1;
                }
                if(s[i]=='$'){
                    flag2++;
                    cnt2=1;
                }
                if(flag2%2==1 && s[i]==' ')
                {
                     cnt2++;
                }
    
                 if(ans>100000)
                      break;
            }
            if(ans>100000)
                 printf("doge
    ");
            else
                 printf("%lld
    ", ans);
        }
        return 0;
    }
    


    每天训练发现我比别人做的好慢,但是理解的更深刻,如果一开始学一个新知识点就搜模板,那么这样的人是走不远的,毕业之后带走的只有思维,什么荣誉,奖杯都已经不重要了。
  • 相关阅读:
    2017-2018-1 团队名称 第一周 作业
    20162307 2017-2018-1 《程序设计与数据结构》第3周学习总结
    20162307 2017-2018-1 《程序设计与数据结构》第1周学习总结
    20161207 结对编程-马尔可夫链-自动生成短文
    20162307 2016-2017-2《程序设计与数据结构》课程总结
    20162307 实验五 网络编程与安全
    20162307 结对编程-四则运算(挑战出题)
    20162306 2016-2017-2《程序设计与数据结构》课程总结
    实验五 网络编程与安全实验报告 20162306陈是奇
    实验补充
  • 原文地址:https://www.cnblogs.com/6bing/p/3931234.html
Copyright © 2011-2022 走看看