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;
}
相关文章推荐
- Mail、计划任务
- STL—利用pair和vector对有序对类型排序
- UNIX域套接字(unix domain)
- WinPAI: FindWindow、FindWindowEx ---查找窗口
- postgreps:The database cluster initialisation failed
- INSTALL_FAILED_SHARED_USER_INCOMPATIBLE的问题
- 怎么提高RailS应用的性能
- 怎么提高RailS应用的性能
- Rails项目中避免滥用这三种特性
- Rails项目中避免滥用这三种特性
- 游戏人工智能开发之进阶版随机技术
- Win7 下Foxmail签名无法修改的解决方案
- AIX系统删除不需要的用户和组
- 位图和矢量图区别,PS和AI的区别
- PyCairo简介
- MIT高级算法公开课视频(无字幕),需要自取-"http://yun.baidu.com/s/1dSPsi“
- Autolayout 描述约束(constraint)语法
- HDU 2473 Junk-Mail Filter(并查集 | 删除操作)
- error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
- 从Git安装Kamailio v4.3.x