Codeforces Beta Round #78 (Div. 2 only)--c help Victoria the Wise__onlinejudge

Source: Internet
Author: User
Tags time limit

Problem solving code problem

Topic Link:
C. Help Victoria the Wise

Time limit per test1 second
Memory limit per test256 megabytes
Inputstandard input
Outputstandard output
Vasilisa the wise from a far away kingdom got a present to her friend Helga the wise from a farther away. The present is a surprise box, yet Vasilisa the Wise doesn ' t know yet what the surprise actually are because she cannot ope n the box. She hopes can help her in that.

The

Box ' s lock is constructed as that. The box itself is represented by a absolutely perfect black cube and the identical deepening on each face (those are SOM E foreign nanotechnologies that the far away Kingdom scientists haven ' t dreamt of). The box is accompanied by six gems whose form matches the deepenings in the box ' s faces. The box can only have opened after it's correctly decorated by the gems, which is, where each deepening contains exactly one Gem. Two ways of decorating the box are considered the same if they can be obtained one to the other one by arbitrarily rotat ing the box (note this box is represented by a perfect nanotechnological cube)

Now Vasilisa the Wise wants to know by the given set of colors the Following:in how many ways would she decorate the box In the worst case to open it? To answer this question it's useful to know, two gems of one color are indistinguishable from each. Help Vasilisa to solve this challenging problem.

Input
The contains exactly 6 characters without spaces from the set {R, O, Y, G, B, V}-they are the colors of gems With which the box should to be decorated.

Output
Print the required number of different ways to decorate the box.

Examples
Inputcopy
Yyyyyy
Output
1
Inputcopy
Boooob
Output
2
Inputcopy
Roygbv
Output
The

The background of the topic is not introduced, now to abstract the question.
Enter a string that contains only the characters in {R, O, Y, G, B, V}, and the length is fixed to 6. This string represents the stickers that are owned, now use these stickers to paste a cube, ask the number of solutions (can be rotated into the exact same solution)

Okay, actually, I have no idea about this problem. Most of what Baidu sees is violence gets the answer, and then the answer is based on the input look-up table, then the violence process is not mentioned (here is presumably a handwritten one count.) Sure I can get the answer, but it's too much trouble. But because I was too lazy to find the official solution to CF, I thought it was very reasonable, and very suitable for my lazy people, so I chose this approach, here to repeat (as a porter).
-First you should know that for a square that has already been painted with color, there are 24 ways to rotate: Choose a different face as the front, so there are 6 kinds, and then keep the face as positive, you can do 4 times (yes, just like turning the handle), get 24.
-The second step is to number each face. For example, the front is 1, the right is 2, the top is 3 ...
-then we can force the color of a cube to be painted with a string (in the order numbered above), then rotate it 24 times, get 24 strings, take the smallest dictionary as the current color, save to set to weight, the last set size is our answer. Code

#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include < algorithm> #include <queue> #include <stack> #include <set> #include <map> #include <
vector> #include <cstring> #include <complex> using namespace std;
typedef long Long LL;
typedef pair<int,int> P;
const int INF = 0X3F3F3F3F;
const int mod = 1E9+7;
const int MAXN =1e3+7;
Const double PI = ACOs (-1.0);
const INT v2 = (mod+1)/2;
Const double EPS = 5e-6;
Char s[6],modle[6] = {' R ', ' O ', ' Y ', ' G ', ' B ', ' V '};
int v[6];
    int Used[24][6] = {{1,2,3,4,5,6},{6,5,4,3,2,1}, {1,3,4,5,2,6},{6,4,3,2,5,1}, {1,4,5,2,3,6},{6,3,2,5,4,1}, {1,5,2,3,4,6},{6,2,5,4,3,1}, {2,6,3,1,5,4},{4,1,3,6,5,2}, {2,3,1,5,6,4},{4,3,6,5,1,2}, {2,1,5,6,3,4},{4,6,5, 1,3,2}, {2,5,6,3,1,4},{4,5,1,3,6,2}, {3,2,6,4,1,5},{5,4,6,2,1,3}, {3,6,4,1,2,5},{5,6,2,1,4,3}, {3,4,1,2,6
, 5},{5,2,1,4,6,3}, {3,1,2,6,4,5},{5,1,4,6,2,3},}; Set&lT;string> St;
    void did (string s) {string res = s;
        for (int i = 0;i < 24;i++) {string tmp = "";
        for (int j = 0;j < 6;j++) {tmp+=s[used[i][j]-1];
        } if (Res.compare (TMP) >0) {res = TMP;
} st.insert (res);
        } void Dfs (int now,string ns) {if (now==6) {did (NS);
    return;
            for (int i = 0;i < 6;i++) {if (v[i]!=0) {v[i]--;
            DFS (Now+1,ns+modle[i]);
        v[i]++;
    int main () {scanf ("%s", s);
            for (int i = 0;i < 6;i++) {for (int j = 0;j < 6;j++) {if (modle[j]==s[i))
            {v[j]++;
    }} DFS (0, "");
    Cout<<st.size () <<endl;
return 0; }

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.