您的位置:首页 > 其它

codeforces #78 div2 C

2011-07-24 23:42 176 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: