Scansion
Capba is doing a poetry analysis. He has scanned the lines of a poem and determined which syllables are stressed and which are unstressed. There are nineteen different "feet", that is, patterns of stressed and unstressed syllables. 0 represents an unstressed syllable and 1 represents a stressed syllable:00 pyrrhic 01 iamb 10 trochee 11 spondee 000 tribrach 001 anapest 010 amphibrach 011 bacchius 100 dactyl 101 amphimacer 110 antibacchius 111 molossos 0001 fourth paeon 0010 third paeon 0011 ionic a minore 0100 second paeon 0110 antispast 1000 first paeon 1001 choriamb
A line with the pattern 001001, for example could be
two anapests;
a pyrrhic, a trochee, and an iamb;
a pyrrhic and a choriamb; or
a third paeon and an iamb.
Capba is having some trouble determining which.
He decides to guess the breakdown of the line into feet, and, through extensive shovelling, justify his assertion whether or not it be right (this leads to excellent results if done properly.) He would like to know how many different ways each line can be broken down into the feet as listed above.
Input Format:
Line 1: A sequence of ones or zeroes, up to 10000 characters long, corresponding to a pattern of stressed and unstressed syllables. 0 represents an unstressed syllable, 1 represents a stressed syllable.
Output Format:
An integer, on a single line - the number of ways that the given line can be broken down into feet, modulo 10007.
Sample Input:
001001
Sample Output:
4
All Submissions
Best Solutions
Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Jan 24, 2009
Author: bbi5291
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
It's kinda stupid I didn't realize that, but I think it would be better to include that in the problem description as well.
I can never figure out stressed/unstressed syllables.
Properly.
Am I exceeding stack space?
Are the strings passed by value not set to 10k chars?
Is it something wrong with the memoizing?
Make recursive vars global whenever possible.
Brian, I can't believe you put him in a problem =P