UVA 253

来源:互联网 发布:老挝嫖尸妓院图片知乎 编辑:程序博客网 时间:2024/05/17 07:26

题目大意:两个正方体,前六个字符代表第一个正方体按图中的编号,进行涂色。后六个字符代表第二个正方体按图中的编号,进行涂色。问能不考虑编号,第一个和第二个正方体是否一样。

解题思路:题目给的编号太麻烦不好判断,将编号顺序改为对面为一对。123456的编号改为162534。排序后判断两个编号是否一致。

ac代码:

#include <iostream>#include <algorithm>using namespace std;char ch[20], t1, t2;int jud;struct node{char a;char b;}no[6];bool compare(node a, node b){if (a.a != b.a)return a.a<b.a;return a.b < b.b;}void change(int n){for (int i=0; i<6; i+=2){t1 = ch[i+n], t2 = ch[6+n-i-1];if (t1 > t2)no[n/2+i/2].a = t1, no[n/2+i/2].b = t2;elseno[n/2+i/2].a = t2, no[n/2+i/2].b = t1;}}int main(){while (scanf("%s", ch)!=EOF){jud = 1;change(0);change(6);sort(no, no+3, compare);sort(no+3, no+6, compare);for (int i=0; i<3; i++)if (no[i].a != no[i+3].a || no[i].b != no[i+3].b)jud = 0;if (jud)printf("TRUE\n");elseprintf("FALSE\n");}return 0;}
原创粉丝点击