#P3448. [POI 2006] MIS-Teddies
[POI 2006] MIS-Teddies
Description
Byteoian is a company specializing in children's toys. Their products are of high quality and well received.
However, it was recently discovered that their teddy bears have a fatal flaw. There are four models of teddy bears: , , , . If three teddy bears with the same letter or the same digit are placed together, it will cause fatal damage.
An arrangement of teddy bears is called safe if there are no three consecutive teddy bears with the same letter or the same digit.
You have collected some teddy bears and want to know how many safe arrangements in a row of all these teddy bears exist. Since the number of safe arrangements can be large, output the result modulo .
Input Format
The input contains four integers: , which denote the numbers of type , , , and teddy bears, respectively.
Output Format
Output a single integer, the number of safe arrangements modulo .
0 1 2 1
6
Hint
Constraints: .
Translated by ChatGPT 5
京公网安备 11011102002149号