#include <iostream>
#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;
char input[36],a[7],b[7],temp[7];
void TurnRight(char* in) {
for (int i = 0; i < 6; ++i)temp[i] = in[i];
in[1] = temp[2];
in[2] = temp[4];
in[3] = temp[1];
in[4] = temp[3];
}
void TrunLeft(char* in) {
for (int i = 0; i < 3; ++i)TurnRight(in);
}
void TurnDown(char* in) {
for (int i = 0; i < 6; ++i)temp[i] = in[i];
in[0] = temp[4];
in[1] = temp[0];
in[4] = temp[5];
in[5] = temp[1];
}
void TrunUp(char* in) {
for (int i = 0; i < 3; ++i)TurnDown(in);
}
bool IsOk(char* a, char* b) {
if (a[0] == b[0]) {
for (int i = 0; i < 4; ++i) {
if (strncmp(a, b, 6) == 0) return true;
TrunLeft(a);
}
}
return false;
}
//六个面分别作为1号 旋转是否能够得到b
bool Check(char* a, char* b) {
char base[7];
memmove(base, a, 6);
if (IsOk(base, b)) return true;
memmove(base, a, 6); TrunLeft(base); TrunUp(base);
if (IsOk(base, b)) return true;
memmove(base, a, 6); TurnRight(base); TrunUp(base);
if (IsOk(base, b)) return true;
memmove(base, a, 6); TurnDown(base);
if (IsOk(base, b)) return true;
memmove(base, a, 6); TrunUp(base);
if (IsOk(base, b)) return true;
memmove(base, a, 6); TurnDown(base); TurnDown(base);
if (IsOk(base, b)) return true;
return false;
}
int main()
{
while (cin >> input) {
memmove(a, input, 6);
memmove(b, input + 6, 6);
if (Check(a, b)) cout << "TRUE" << endl;
else cout << "FALSE" << endl;
}
return 0;
}
习题4-4(uva-253)
最新推荐文章于 2021-03-05 20:52:36 发布