codeforces #78 div2 C

来源:互联网 发布:上海 java 培训机构 编辑:程序博客网 时间:2024/04/29 14:47

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-8string 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;}


原创粉丝点击