algorithms

Algorithm implementations
git clone git://git.laack.co/algorithms.git
Log | Files | Refs | README

problem.txt (1538B)


      1 C. Tiles
      2 time limit per test1 second
      3 memory limit per test256 megabytes
      4 Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below.
      5 
      6 
      7 The dimension of this tile is perfect for this kitchen, as he will need exactly w×h
      8  tiles without any scraps. That is, the width of the kitchen is w
      9  tiles, and the height is h
     10  tiles. As each tile can be rotated in one of four ways, he still needs to decide on how exactly he will tile the floor. There is a single aesthetic criterion that he wants to fulfil: two adjacent tiles must not share a colour on the edge — i.e. one of the tiles must have a white colour on the shared border, and the second one must be black.
     11 
     12 The picture on the left shows one valid tiling of a 3×2
     13  kitchen. The picture on the right shows an invalid arrangement, as the bottom two tiles touch with their white parts.
     14 Find the number of possible tilings. As this number may be large, output its remainder when divided by 998244353
     15  (a prime number).
     16 
     17 ---
     18 
     19 - decorating his kitchen
     20 - tiles are split in half diagonally with black / white
     21 - w x h kitchen
     22 - a given tile has 4 valid rotations
     23 - two adjacent tiles must not share a colour on the edge
     24 - find the number of possible tilings
     25 - return mod 998244353
     26 - w <= 1000
     27 - h <= 1000
     28 - w x h <= 1,000,000
     29 
     30 ---
     31 
     32 - is the answer just (w x h) ** 2?
     33     - this is the case for 22, 24