codeforces #78 div2 C

http://www.codeforces.com/contest/99/problem/C

题意就是问给出了6个颜色(可以相同)涂一个正方体,问能组成多少种不同的情况,注:能旋转的就视为同一种情况

方法:模拟正方体旋转,可以拿一块橡皮试试,例如规定0-前,1-后,2-左,3-右,4-下,5上,依次旋转。

#include<iostream>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include<queue>
#include<list>
#include<set>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdio.h>
#include<ctype.h>
#include<iomanip>

using namespace std;

#define LL long long
#define L long
#define pi acos(-1)
#define N 1100
#define INF 9999999999
#define eps 1e-8


string str[] =
  {
    "012345",
    "041235",
    "034125",
    "023415",
    "104523",
    "120453",
    "152043",
    "145203",
    "215304",
    "201534",
    "230154",
    "253014"
  };
bool equal(string a, string b)
{
  for(int i = 0 ; i < 12; i++)
    {
      string t1;
      for(int j = 0; j < 6; j++)
        t1 += a[ str[i][j] - '0' ];
      if( t1 == b )
        return true;
      string rev = str[i];
      reverse(rev.begin(), rev.end() );
      string t2;
      for(int j = 0 ; j < 6; j++)
        t2 += a[ rev[j] - '0'];
      if( t2 == b )
        return true;
    }
  return false;
}

int main()
{
  //freopen("a.txt","r",stdin);
  string s;
  while(cin >> s)
  {
  sort(s.begin(), s.end());
  vector<string> myset;
  do
    {
      bool already = false;
      for(int i = 0; i < myset.size(); i++)
        if( equal(s, myset[i] ) )
          {
              already = true;
              break;
          }

      if( !already )
        myset.push_back(s);//cout<<s<<endl;
    }while(next_permutation(s.begin(), s.end()));
  cout<<myset.size()<<endl;
  }
  return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值