#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
#define REP(i,n) for(int i = 0;i < (n);i++)
const int maxn = 10;
int n;
char pos[maxn][maxn][maxn];
char view[6][maxn][maxn];
char Read_Char() {
char ch;
while (true) {
cin >> ch;
if (ch >= 'A' && ch <= 'Z' || ch == '.') return ch;
}
}
void get(int k, int i, int j, int len, int& x, int& y, int& z) {
if (k == 0) { x = len; y = j; z = i; }
if (k == 1) { x = n - 1 - j; y = len; z = i; }
if (k == 2) { x = n - 1 - len; y = n - 1 - j; z = i; }
if (k == 3) { x = j; y = n - 1 - len; z = i; }
if (k == 4) { x = n - 1 - i; y = j; z = len; }
if (k == 5) { x = i; y = j; z = n - 1 - len; }
}
int main()
{
while (cin >> n && n) {
REP(i, n) REP(k, 6) REP(j, n) view[k][i][j] = Read_Char();
REP(i, n) REP(j, n) REP(k, n) pos[i][j][k] = '#';
REP(k,6) REP(i,n) REP(j,n) if(view[k][i][j] == '.')
REP(p, n) {
int x, y, z;
get(k,i,j,p,x,y,z);
pos[x][y][z] = '.';
}
while (true) {
bool done = true;
REP(k, 6) REP(i, n) REP(j, n) if (view[k][i][j] != '.') {
REP(p, n) {
int x, y, z;
get(k, i, j, p,x, y, z);
if (pos[x][y][z] == '.')continue;
if (pos[x][y][z] == '#') {
pos[x][y][z] = view[k][i][j];
break;
}
if (pos[x][y][z] == view[k][i][j]) break;
pos[x][y][z] = '.';
done = false;
}
}
if (done) break;
}
int ans = 0;
REP(i, n) REP(j, n) REP(k, n)
if (pos[i][j][k] != '.')++ans;
cout << "Maximum weight: "<<ans<<" gram(s)" << endl;
}
return 0;
}
uva1030
于 2022-03-28 21:49:00 首次发布