# | User | Rating |
---|---|---|

1 | tourist | 3581 |

2 | OO0OOO00O0OOO0O0…O | 3264 |

3 | mnbvmar | 3246 |

4 | LHiC | 3183 |

5 | Um_nik | 3176 |

6 | Petr | 3161 |

7 | Radewoosh | 3128 |

8 | CongLingDanPaiSh…5 | 3116 |

9 | ainta | 3115 |

9 | ko_osaga | 3115 |

# | User | Contrib. |
---|---|---|

1 | Radewoosh | 190 |

2 | Errichto | 166 |

3 | rng_58 | 161 |

4 | tourist | 158 |

5 | Vovuh | 150 |

5 | Um_nik | 150 |

7 | Petr | 149 |

7 | Swistakk | 149 |

9 | 300iq | 148 |

10 | PikMike | 147 |

10 | neal | 147 |

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/22/2018 16:17:19 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

please help ... it would be kind..

Since the height of the corridor is five, the problem can be solved with a bitmask DP, where you would have as your states your current coordinate and the bitmask for the current column and the next column. You should traverse the corridor in the following manner: Place tatami at position (i, j) (if you haven't placed one beforehand) and then go to (i + 1, j). If i = 5, it means you have already completed that column and should proceed to (0, j + 1).

The bitmask would store which of the squares have already been occupied by tatamis. If your current square has already been occupied by a tatami, skip it. Otherwise, there are two ways to place it: Horizontally, occupying spots (i, j) and (i, j + 1) or Vertically, occupying (i, j) and (i + 1, j).

Say bits in positions [0, 4] will reference the current column and [5, 9] the next column. If you place a tatami horizontally, you should activate bits i and i + 5 to represent that those positions have been occupied. If you place it vertically, activate bits i and i + 1. Once your i coordinate has reached 5, the first 5 bits of the bitmask will no longer be relevant, since these such bits are a reference to the column that you have already passed by. In that case, you can do mask >>= 5 to shift the bits from [5, 9] to [0, 4].

thanks a lot .....