11238 - Innoumerous bowling games

All about problems in Volume 112. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
sikder1588
New poster
Posts: 5
Joined: Thu Jun 21, 2012 9:11 am

11238:: Why WA? Where is the problem?

Post by sikder1588 »

Code: Select all

#include <iostream>
#include <stdio.h>
#include <map>
#include <string.h>
#include <queue>
using namespace std;
long long dp[305][13][4];

long long DP(int left,int at,int b)
{
    long long ans,now;
    ans=0;
    int i,j,score,sc;

    if(left<0)  return 0;
    if(at==10)
    {
        if(b==0)
        {
          if(left==0) return 1;
          return 0;
        }
        if(b==1)
        {
            for(i=0;i<11;i++)
            {
                now=DP(left-i,at+1,0);
                ans+=now;
            }
        }
        if(b>1)
        {
            for(i=0;i<11;i++)
            {
                if(b==3) sc=i*2;
                if(b==2) sc=i;
                if(i==10)
                {
                    for(j=0;j<11;j++)
                    {
                        score=sc+j;
                        now=DP(left-score,at+1,0);
                        ans+=now;
                    }
                    continue;
                }
                for(j=0;j<(11-i);j++)
                {
                    score=sc+j;
                    now=DP(left-score,at+1,0);
                    ans+=now;
                }
            }
        }
        dp[at][left][b]=ans;
        return ans;
    }

    if(at==11)
    {
        if(left==0) return 1;
        return 0;
    }

    if(dp[left][at][b]!=(-1))
        return dp[left][at][b];
    ans=0;
    for(i=0;i<11;i++)
    {
        if(b==3)
            sc=i*3;
        if(b==2 || b==1)
            sc=i*2;
        if(b==0)
            sc=i;
        if(i==10)
        {
            if(b==3 || b==2)
                now=DP(left-sc,at+1,3);
            if(b==1 || b==0)
                now=DP(left-sc,at+1,2);
            ans+=now;
            continue;
        }
        for(j=0;j<(11-i);j++)
        {
            if(b>1) score=sc+j*2;
                else score=sc+j;
            if((i+j)!=10)
                now=DP(left-score,at+1,0);
            if((i+j)==10)
                now=DP(left-score,at+1,1);
            ans+=now;
        }
    }
    dp[left][at][b]=ans;

    return ans;
}
int main()
{
    long long ans;
    int s;
   // freopen("a.out","w",stdout);

    while(1)
    {
        scanf("%d",&s);

        if(s==(-1))
            break;

        memset(dp,-1,sizeof(dp));
        ans=DP(s,0,0);

        printf("%lld\n",ans);
    }
    return 0;
}


Keep Going
Bristy Sikder
sikder1588
New poster
Posts: 5
Joined: Thu Jun 21, 2012 9:11 am

11238 - Innoumerous bowling games

Post by sikder1588 »

I am not understanding the problem. Can anyone please explain me??

Keep Going
Bristy Sikder
sikder1588
New poster
Posts: 5
Joined: Thu Jun 21, 2012 9:11 am

Re: 11238: Help

Post by sikder1588 »

If the person gets 10 points in the last frame.
What happens if it is a strike??
What happens if it a spare??

In the last two bonus attempts, its it possible to score 9,8 or sth like this?

Keep Going
Bristy Sikder
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11238: Help

Post by brianfry713 »

For each test case, print the number of different bowling games resulting in the given score in one line.

Look up the rules of bowling. The problem statement is clear. In the 10th frame, if you get a strike you get two more attempts. If you get a spare you get one more attempt.
Check input and AC output for thousands of problems on uDebug!
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11238:: Why WA? Where is the problem?

Post by brianfry713 »

Doesn't match the sample I/O.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 112 (11200-11299)”