您的位置:首页 > 大数据 > 人工智能

uva 253 Cube painting

2015-09-06 21:00 281 查看

思路:

    选择立方体一面为参照面有6中可能,直接硬编码。每种参照情况下,选择侧面能构建再4种情况。

// Created by Chenhongwei in 2015.
// Copyright (c) 2015 Chenhongwei. All rights reserved.

#include "iostream"
#include "cstdio"
#include "cstdlib"
#include "cstring"
#include "climits"
#include "queue"
#include "cmath"
#include "map"
#include "set"
#include "stack"
#include "vector"
#include "sstream"
#include "algorithm"
using namespace std;
const int inf = 1e8;
const int maxn = 20;
typedef long long ll;
typedef unsigned long long ull;
int dir[6][6] = { {0, 1, 2, 3, 4, 5}, {1, 5, 2, 3, 0, 4}, {2, 1, 5, 0, 4, 3},
{3, 1, 0, 5, 4, 2}, {4, 0, 2, 3, 5, 1}, {5, 4, 2, 3, 1, 0}
};
char str[20], str1[20], str2[20];
bool rotate() {
char temp[20] = {0};
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
temp[j] = str1[dir[i][j]];
for (int j = 0; j < 4; j++)
{
char cha;
cha = temp[1];
temp[1] = temp[2];
temp[2] = temp[4];
temp[4] = temp[3];
temp[3] = cha;
if (strcmp(temp, str2) == 0)
return true;
}
}
return false;
}

int main()
{
//ios::sync_with_stdio(false);
// freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while (scanf("%s", str) != EOF)
{
for (int i = 0; i < 6; i++)
str1[i] = str[i];
for (int i = 0; i < 6; i++)
str2[i] = str[i + 6];
if (rotate())
puts("TRUE");
else
puts("FALSE");
}
return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: