|
ADS
Algorithms and Data Structures
|
The square tiling (BOUNDED TILING, the DOMINO LIMITATO of the book) of chapter 18: \( n \times n \) squares to cover with copies of \( m \) oriented tiles, each split by its diagonals into four colored quarters, never rotated, the tile \( d = D[ 0 ] \) in the corner \( ( 0 , 0 ) \), and touching sides of the same color. More...
#include "ADS/Contract.h"#include <algorithm>#include <cstddef>#include <optional>#include <vector>#include "ADS/complexity/impl/Domino.tpp"Go to the source code of this file.
Classes | |
| struct | ADS::Tile |
| a tile: the colors of its four sides More... | |
Namespaces | |
| namespace | ADS |
Typedefs | |
| using | ADS::Tiling = std::vector< std::vector< int > > |
| the tile of ( i , j ) | |
Functions | |
| bool | ADS::legalTiling (const std::vector< Tile > &D, int n, const Tiling &T) |
| whether \( T \) is a legal covering of the \( n \times n \) square by \( D \), with \( d = D[ 0 ] \) in \( ( 0 , 0 ) \); false if \( n < 1 \), if \( T \) is not \( n \times n \) or if a tile of \( T \) is not one of \( D \) | |
| std::optional< Tiling > | ADS::squareTiling (const std::vector< Tile > &D, int n) |
| a legal covering of the \( n \times n \) square, by backtrack, or nothing (also if \( n < 1 \) or \( D \) is empty) | |
| bool | ADS::linearTiling (const std::vector< Tile > &D, long n) |
| whether a strip of \( n \) tiles from \( d = D[ 0 ] \) exists, \( O( m^2 ) \); false if \( n < 1 \) or \( D \) is empty, true for any \( n \) if a cycle of tiles that fit is reachable from \( d \) | |
The square tiling (BOUNDED TILING, the DOMINO LIMITATO of the book) of chapter 18: \( n \times n \) squares to cover with copies of \( m \) oriented tiles, each split by its diagonals into four colored quarters, never rotated, the tile \( d = D[ 0 ] \) in the corner \( ( 0 , 0 ) \), and touching sides of the same color.
The square \( ( i , j ) \) is the column \( i \) and the row \( j \) from the bottom left; a tile is left of the one in \( ( i + 1 , j ) \) and below the one in \( ( i , j + 1 ) \).
legalTiling() is the certificate, \( O( n^2 ) \); squareTiling() the enumeration by backtrack of the \( m^{n^2 - 1} \) coverings, pruned at the first wrong side. linearTiling() solves the linear tiling, a strip \( 1 \times n \), in polynomial time: by the reduction of the text, the tiles are the nodes of a graph with an edge \( ( d_u , d_v ) \) when the right side of \( d_u \) has the color of the left side of \( d_v \), and a strip is a walk of \( n - 1 \) edges from \( d \), which exists if and only if a cycle is reachable from \( d \) or the longest path from \( d \), in the acyclic part, has \( n - 1 \) edges; \( O( m^2 ) \) time.
The contracts [see Contract.h]: a covering returned by squareTiling() is checked by legalTiling(); the certificate and the linear tiling accept any input. The operations are defined in Domino.tpp.