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;
    }
    


    每天训练发现我比别人做的好慢,但是理解的更深刻,如果一开始学一个新知识点就搜模板,那么这样的人是走不远的,毕业之后带走的只有思维,什么荣誉,奖杯都已经不重要了。
  • 相关阅读:
    SVN更新及如何解决冲突文件
    Eclipse如何删除多建的Tomcat服务器
    linux查看硬件配置命令
    【项目经验】navicat工具 SQLServer数据库迁移MySQL
    Oracle 中的 时间运算
    1001 数组中和等于K的数对
    1004 n^n的末位数字
    1182 完美字符串
    1283 最小周长
    1284 2 3 5 7的倍数
  • 原文地址:https://www.cnblogs.com/6bing/p/3931234.html
Copyright © 2011-2022 走看看