#include typedef struct { int x[3], m; } loc_t; #define MAX_NR_LOC 400 #define MAX_NR_LOC_IN_PIECE 20 #define MAX_NR_ORIENTS 1000 loc_t locs[MAX_NR_LOC]; int nr_locs = 0; int dim; int has_marker; int nr_pieces; loc_t piece[MAX_NR_LOC_IN_PIECE]; int nr_p_locs; int kind; int orients[MAX_NR_ORIENTS][MAX_NR_LOC_IN_PIECE]; int nr_orients; int rot[24][3] = { { 1, 2, 3 }, { 2, -1, 3 }, { -1, -2, 3 }, { -2, 1, 3 }, { 1, -2, -3 }, { 2, 1, -3 }, { -1, 2, -3 }, { -2, -1, -3 }, { 2, 3, 1 }, { -3, 2, 1 }, { -2, -3, 1 }, { 3, -2, 1 }, { 2, -3, -1 }, { -3, -2, -1 }, { -2, 3, -1 }, { 3, 2, -1 }, { 3, 1, 2 }, { -1, 3, 2 }, { -3, -1, 2 }, { 1, -3, 2 }, { 3, -1, -2 }, { -1, -3, -2 }, { -3, 1, -2 }, { 1, 3, -2 }, }; int main(int argc, int argv) { int l,p; scanf("%d %d", &dim, &has_marker); scanf("%d", &nr_locs); for (l = 0; l < nr_locs; l++) { locs[l].x[0] = 0; locs[l].x[1] = 0; locs[l].x[2] = 0; locs[l].m = 0; scanf("%d", &locs[l].x[0]); if (dim > 1) scanf("%d", &locs[l].x[1]); if (dim > 2) scanf("%d", &locs[l].x[2]); if (has_marker) scanf("%d", &locs[l].m); /* printf("loc %d: %d %d %d %d\n", l, locs[l].x[0], locs[l].x[1], locs[l].x[2], locs[l].m); */ } scanf("%d", &nr_pieces); printf("%d\n%d\n", nr_locs, nr_pieces); for (p = 0; p < nr_pieces; p++) { int i, r, o; scanf("%d %d", &nr_p_locs, &kind); for (l = 0; l < nr_p_locs; l++) { piece[l].x[0] = 0; piece[l].x[1] = 0; piece[l].x[2] = 0; piece[l].m = 0; scanf("%d", &piece[l].x[0]); if (dim > 1) scanf("%d", &piece[l].x[1]); if (dim > 2) scanf("%d", &piece[l].x[2]); if (has_marker) scanf("%d", &piece[l].m); if (l > 0) { piece[l].x[0] -= piece[0].x[0]; if (dim > 1) piece[l].x[1] -= piece[0].x[1]; if (dim > 2) piece[l].x[2] -= piece[0].x[2]; } } nr_orients = 0; switch (kind) { case 1: r = 1; break; case 2: r = 4; break; case 3: r = 24; break; } for (l = 0; l < nr_locs; l++) for (i = 0; i < r; i++) { int pl; int fits = piece[0].m == locs[l].m; int p_locs[MAX_NR_LOC_IN_PIECE]; p_locs[0] = l; for (pl = 1; pl < nr_p_locs && fits; pl++) { int n[3], j; int ml; for (j = 0; j < 3; j++) if (rot[i][j] < 0) n[j] = locs[l].x[j] - piece[pl].x[-rot[i][j]-1]; else n[j] = locs[l].x[j] + piece[pl].x[rot[i][j]-1]; fits = 0; for (ml = 0; ml < nr_locs; ml++) { fits = n[0] == locs[ml].x[0] && n[1] == locs[ml].x[1] && n[2] == locs[ml].x[2] && piece[pl].m == locs[ml].m; if (fits) break; } if (fits) { int v = 0, v2; while (v < pl && p_locs[v] < ml) v++; for (v2 = pl - 1; v2 >= v; v2--) p_locs[v2+1] = p_locs[v2]; p_locs[v] = ml; } } if (fits) { /* p_locs contains sorted list of locations */ int io, found = 0, j; /**** for (j = 0; j < nr_p_locs; j++) printf("%d ", p_locs[j]); printf(": %d %d\n", i, r); ****/ /* check it is occurs in orients, if not add: */ for (io = 0; io < nr_orients && !found; io++) { found = 1; for (j = 0; j < nr_p_locs && found; j++) found = orients[io][j] == p_locs[j]; } if (!found && nr_orients < MAX_NR_ORIENTS) { for (j = 0; j < nr_p_locs; j++) orients[nr_orients][j] = p_locs[j]; nr_orients++; } } } printf(" %d\n", nr_orients); for (o = 0; o < nr_orients; o++) { int pl; printf(" %d ", nr_p_locs); for (pl = 0; pl < nr_p_locs; pl++) printf(" %d", orients[o][pl]); printf("\n"); } } return 0; }