Timus 1127

#include <iostream>
#include
<map>
#include
<string>
using namespace std;


int counter[10001] = { 0 };
int ret = -1;

int to_digit(char color) {
switch(color) {
case 'A': return 0;
case 'B': return 1;
case 'C': return 2;
case 'G': return 3;
case 'O': return 4;
case 'R': return 5;
case 'S': return 6;
case 'V': return 7;
case 'W': return 8;
case 'Y': return 9;
}
}

void to_digit_seq(char n1, char n2, char n3, char n4) {
int a, b, c, d;
a
= to_digit(n1) * 1000 + to_digit(n2) * 100 + to_digit(n3) * 10 + to_digit(n4);
b
= to_digit(n2) * 1000 + to_digit(n3) * 100 + to_digit(n4) * 10 + to_digit(n1);
c
= to_digit(n3) * 1000 + to_digit(n4) * 100 + to_digit(n1) * 10 + to_digit(n2);
d
= to_digit(n4) * 1000 + to_digit(n1) * 100 + to_digit(n2) * 10 + to_digit(n3);

counter[a]
++;
counter[b]
++;
counter[c]
++;
counter[d]
++;

if( counter[a] > ret )
ret
= counter[a];
}

int main() {

int N, i, j, k;
string dice;
cin
>>N;

for( i=0;i<N;i++ ) {
cin
>>dice;

to_digit_seq(dice[
0], dice[2], dice[3], dice[1]);
to_digit_seq(dice[
0], dice[1], dice[3], dice[2]);
to_digit_seq(dice[
0], dice[4], dice[3], dice[5]);
to_digit_seq(dice[
0], dice[5], dice[3], dice[4]);
to_digit_seq(dice[
5], dice[2], dice[4], dice[1]);
to_digit_seq(dice[
5], dice[1], dice[4], dice[2]);
}

cout
<<ret<<endl;

return 0;
}

题目要求用N个正方体,数据确保正方体没有两个面是相同颜色的。

然后要求用这N个正方体堆叠出一个最高的,而且每个侧面都是只由一种颜色构成的“塔”

题目关键是分析出每个正方体能构成什么侧面。

按题目所言,用0,1,2,3,4,5分别代表:前、右、左、后、上、下

那么一个正方体就有以下6种侧面:

0、2、3、1

0、1、3、2

0、4、3、5

0、5、3、4

5、2、4、1

5、1、4、2。

posted @ 2011-08-18 10:40  DOF_KL  阅读(206)  评论(0编辑  收藏  举报