1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| const int maxn = 10 + 1; int n;
char p[maxn][maxn][maxn]; char view[maxn][maxn][maxn];
char read() { char ch; for(;;) { ch = getchar(); if ((ch >= 'A' && ch <= 'Z') || ch == '.') return ch; } }
inline void data(int k, int i, int j, int lv, int &x, int &y, int &z) { if (k == 0) { x = lv; y = j; z = i; } if (k == 1) { x = n-1-j; y = lv; z = i; } if (k == 2) { x = n-1-lv; y = n-1-j; z = i; } if (k == 3) { x = j; y = n-1-lv; z = i; } if (k == 4) { x = n-1-i; y = j; z = lv; } if (k == 5) { x = i; y = j; z = n-1-lv; } }
void getdata() { _for(i, 0, n) _for(k, 0, 6) _for(j, 0, n) { view[k][i][j] = read(); }
_for(x, 0, n) _for(y, 0, n) _for(z, 0, n) p[x][y][z] = '#'; _for(k, 0, 6) _for(i, 0, n) _for(j, 0, n) if (view[k][i][j] == '.') { _for(lv, 0, n) { int x, y, z; data(k, i, j, lv, x, y, z); p[x][y][z] = '.'; } } }
void dfs() { bool done = true;
_for(k, 0, 6) _for(i, 0, n) _for(j, 0, n) if (view[k][i][j] != '.') { _for(lv, 0, n) { int x, y, z; data(k, i, j, lv, x, y, z);
if (p[x][y][z] == '.') continue; if (p[x][y][z] == '#') { p[x][y][z] = view[k][i][j]; break; } if (p[x][y][z] == view[k][i][j]) break;
p[x][y][z] = '.'; done = false; } }
if (!done) dfs(); return; }
void init() { memset(view, 0, sizeof(view)); memset(p, 0, sizeof(p)); }
int main() { freopen("input.txt", "r", stdin); while (scanf("%d", &n) == 1 && n) { init();
// then get data getdata();
// then dfs dfs(); int ans = 0; _for(x, 0, n) _for(y, 0, n) _for(z, 0, n) if (p[x][y][z] != '.') ans++; //debug(ans);
printf("Maximum weight: %d gram(s)\n", ans); } }
|