UVA-253 Cube Painting

Source: Internet
Author: User

Cube painting
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

Submit Status

Description

We have a painting cubes. It is supplied with three different colors:blue, red and green. Each face of the cube gets one of these colors. The cube ' s faces is numbered as in Figure 1.

Figure 1.

since a cube has 6 faces, we can paint a face-numbered cube in     different ways. When ignoring the face-numbers, the number of different paintings was much less, because a-cube can be rotated. See example below. We denote a painted cube by a string of 6 characters, where each character is a   b ,  < /span> R , or   g . The     character (     ) from the left gives the Color of face   i . For example, Figure 2 was a picture of the   rbgggr   and Figure 3 corresponds To   rggbgr . Notice that both cubes is painted in the same way:by rotating it around the vertical axis by +     , the one changes into the other.

Input

The input of your program was a textfile that ends with the standard end-of-file marker. Each line is a string of characters. The first 6 characters of this string is the representation of a painted cube, the remaining 6 characters give you the RE Presentation of another cube. Your program determines whether these-cubes is painted on the same, that's, whether by any combination of Rotati ONS one can be turned to the other. (Reflections is not allowed.)

Output

The output is a file of Boolean. For each line of input, output contains TRUE If the second half can is obtained from the first Half by rotation as describes above, FALSE otherwise.

Sample Input
Rbgggrrggbgrrrrbbbrrbbbrrbgrbgrrrrrg
Sample Output
Truefalsefalse

is fixed up and down unchanged, the rotation of the remaining four faces, each change upward of the face, will enumerate all 6*4 a different posture, and then compared with the second dice, the point of space imagination, not to take a hand-called things under the gesture will come out, there are rotating attention to the next posture.

#include <iostream> #include <cstring> #include <string> #include <cstdio>using namespace std;   List the different faces up is the number of each position int dir[6][6] = {{0, 1, 2, 3, 4, 5}, {1, 0, 3, 2, 5, 4}, {2, 0, 1, 4, 5, 3}, {3, 0, 4, 1, 5, 2}, {4, 0, 2, 3, 5, 1}, {5, 1, 3, 2, 4, 0}};char A[10];char b[10];char s[20];bool judge () {for (int i = 0; i < 6; i++) {char temp[10] = ""; for (int j = 0; J < 6; J + +)  //dice gesture for each of the different numbers upward temp[j] = a[dir[i][j]];for (int j = 0; J < 4; J + +) {char c_temp;c_temp = temp[1];  Rotation, note yy out rotation is the way the number changes temp[1] = temp[2];temp[2] = temp[4];temp[4] = temp[3];temp[3] = c_temp;if (strcmp (temp, b) = = 0) retur n True;}} return false;} int main () {while (scanf ("%s", s)! = EOF) {for (int i = 0; i < 6; i++) a[i] = s[i];a[6] = 0;for (int i = 0; i < 6; i++) B[i] = s[i + 6];b[6] = 0;if (judge ()) cout << "TRUE" << endl;else cout << "FALSE" << Endl;}}


UVA-253 Cube Painting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.