LA 3401 Colored Cubes 暴力 -
来源:互联网 发布:为什么淘宝图片不清晰 编辑:程序博客网 时间:2024/05/18 21:05
题目地址:http://vjudge.net/problem/UVALive-3401
#include <bits/stdc++.h>using namespace std;#define REP(i,a,b) for(int i=(a);i<=(b);++i)const int maxn=5;int dice24[24][6]= { //这24种都是相同的{2,1,5,0,4,3},{2,0,1,4,5,3},{2,4,0,5,1,3},{2,5,4,1,0,3},{4,2,5,0,3,1},{5,2,1,4,3,0},{1,2,0,5,3,4},{0,2,4,1,3,5},{0,1,2,3,4,5},{4,0,2,3,5,1},{5,4,2,3,1,0},{1,5,2,3,0,4},{5,1,3,2,4,0},{1,0,3,2,5,4},{0,4,3,2,1,5},{4,5,3,2,0,1},{1,3,5,0,2,4},{0,3,1,4,2,5},{4,3,0,5,2,1},{5,3,4,1,2,0},{3,4,5,0,1,2},{3,5,1,4,0,2},{3,1,0,5,4,2},{3,0,4,1,5,2}};int color[maxn][6],dice[maxn][6],r[maxn],n,ans;map<string, int> ID;void Check(){REP(i,0,n-1) REP(j,0,5) color[i][dice24[r[i]][j]]=dice[i][j];int tot=0;REP(j,0,5){int MaxColor=0; //找出该面同种颜色最多出现次数int cnt[maxn*6]={0};REP(i,0,n-1) MaxColor=max(MaxColor,++cnt[color[i][j]]);tot+=n-MaxColor; //要涂n-MaxCloor个}ans=min(ans,tot);}void DFS(int cur){if(cur==n) Check();else REP(i,0,23) {r[cur]=i;DFS(cur+1);} }int main(int argc, char const *argv[]){// init();while(scanf("%d",&n)==1&&n){ID.clear();REP(i,0,n-1) REP(j,0,5){string name;cin>>name;int id;if(ID.count(name)) id=ID[name];else id=ID.size(),ID[name]=id;dice[i][j]=id;}ans=n*6;r[0]=0; //固定一个立方体不旋转DFS(1);printf("%d\n", ans);}return 0;}/*const int Left[]={4,0,2,3,5,1}; //左旋转const int up[]={2,1,5,0,4,3}; //上旋转void rot(const int* T,int* p){ int q[6];memcpy(q,p,sizeof(q));REP(i,0,5) p[i]=T[q[i]];}void enumerate_permutation(){int p0[6]={0,1,2,3,4,5};printf("int dice24[24][6] = {\n");REP(i,0,5) {int p[6]; //p[i] 代表i数字出现在p[i]面memcpy(p,p0,sizeof(p0));if(i==0) rot(up,p);if(i==1) rot(Left,p),rot(up,p);if(i==3) rot(up,p),rot(up,p);if(i==4) rot(Left,p),rot(Left,p),rot(Left,p),rot(up,p);if(i==5) rot(Left,p),rot(Left,p),rot(up,p);REP(j,0,3) {printf("{%d,%d,%d,%d,%d,%d},\n",p[0],p[1],p[2],p[3],p[4],p[5]);rot(Left,p);}}printf("};\n");}void init(){enumerate_permutation();}*/
0 0
- LA 3401 Colored Cubes 暴力 -
- LA 3401 - Colored Cubes
- LA 3401 - Colored Cubes
- LA 3401 Colored Cubes
- LA 3041 Colored Cubes (暴力枚举+贪心)
- uvaLive 3401 Colored Cubes 暴力
- UVALive 3401 Colored Cubes
- UVALive - 3401 Colored Cubes
- UVALive - 3401 Colored Cubes
- 3401 - Colored Cubes
- UVALive 3401 Colored Cubes
- UVa-3401 Colored Cubes
- uva1352 - Colored Cubes 打表+暴力
- UVAL colored cubes 打表 暴力枚举
- UVA 1352 Colored Cubes(暴力搜索枚举)
- UVALive - 3401 Colored Cubes 枚举
- Colored Cubes
- Colored Cubes
- Android Drawable--Shape
- MYSQL主主复制
- 链表模板(头插模块)
- Markdown - 写博客,从语法开始
- 单词接龙
- LA 3401 Colored Cubes 暴力 -
- redhat-linux 学习6 :linux 设置网关和ip
- 自写php字符串从小到大排序函数
- Python装饰器学习
- Hessian源码分析--HessianServlet
- Java : 一个帝国的诞生
- 数据库学习笔记 --- SQL查询数据库中所有的表
- 二维字符串指针
- 链栈的基本操作实现(c语言)