K - Pocket Cube

Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

Pocket Cube is a 3-D combination puzzle. It is a 2 × 2 × 2 cube, which means it is constructed by 8 mini-cubes. For a combination of 2 × 2 mini-cubes which sharing a whole cube face, you can twist it 90 degrees in clockwise or counterclockwise direction, this twist operation is called one twist step. 
Considering all faces of mini-cubes, there will be totally 24 faces painted in 6 different colors (Indexed from 0), and there will be exactly 4 faces painted in each kind of color. If 4 mini-cubes' faces of same color rely on same large cube face, we can call the large cube face as a completed face.

Now giving you an color arrangement of all 24 faces from a scrambled Pocket Cube, please tell us the maximum possible number of completed faces in no more than N twist steps. 
Index of each face is shown as below:

 

Input

There will be several test cases. In each test case, there will be 2 lines. One integer N (1 ≤ N ≤ 7) in the first line, then 24 integers Ci separated by a single space in the second line. For index 0 ≤ i < 24, Ci is color of the corresponding face. We guarantee that the color arrangement is a valid state which can be achieved by doing a finite number of twist steps from an initial cube whose all 6 large cube faces are completed faces.
 

Output

For each test case, please output the maximum number of completed faces during no more than N twist step(s).
 

Sample Input

1
0 0 0 0 1 1 2 2 3 3 1 1 2 2 3 3 4 4 4 4 5 5 5 5
1
0 4 0 4 1 1 2 5 3 3 1 1 2 5 3 3 4 0 4 0 5 2 5 2
 

Sample Output

6
2
 
转魔方,bfs,一直找不到wa在哪里。这题思考魔方的旋转有点烦。
有6种旋转方式,而不是12种。。
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#define INF 0x3f3f3f3f
#define M(a,b) memset(a,b,sizeof(a)) using namespace std; int state[];
int change[][]={
{,,,,,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,,,,,},
{,,,,,,,,,,,,,,,,,,,,,,,},
}; int N;
int ans; struct tube
{
int d[];
int cnt;
tube(){}
};
tube st;
tube trans(tube tmp,int k)
{
tube res; for (int i=; i<; i++)
res.d[i]=tmp.d[change[k][i]]; return res;
}
int count(tube tmp)
{
int res=;
if (tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[]) res++;
if (tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[]) res++;
if (tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[]) res++;
if (tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[]) res++;
if (tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[]) res++;
if (tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[] && tmp.d[]==tmp.d[]) res++;
return res;
} void bfs()
{
queue<tube> q;
q.push(st);
// map<tube,int> mp;
// mp[st]=1;
ans=count(st);
while(!q.empty())
{
tube now=q.front();
q.pop();
tube tmp;
for (int i=; i<; i++)
{
tmp=trans(now,i);
tmp.cnt=now.cnt+;
// if (mp.find(tmp)!=mp.end())
// {
// mp[tmp]=1;
// ans=max(ans,count(tmp));
// if (tmp.cnt<num) q.push(tmp);
// }
ans=max(ans,count(tmp));
if (tmp.cnt<N) q.push(tmp);
}
}
} int main()
{
//init();
while(scanf("%d",&N)==)
{
for(int i = ;i<;i++)
{
scanf("%d",&st.d[i]);
}
st.cnt=;
bfs();
printf("%d\n",ans);
}
return ;
}

2013区域赛长沙赛区现场赛 K - Pocket Cube的更多相关文章

  1. 2014年亚洲区域赛北京赛区现场赛A,D,H,I,K题解(hdu5112,5115,5119,5220,5122)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 下午在HDU上打了一下今年北京区域赛的重现,过了5题,看来单挑只能拿拿铜牌,呜呜. ...

  2. HDU 4793 Collision (解二元一次方程) -2013 ICPC长沙赛区现场赛

    题目链接 题目大意 :有一个圆硬币半径为r,初始位置为x,y,速度矢量为vx,vy,有一个圆形区域(圆心在原点)半径为R,还有一个圆盘(圆心在原点)半径为Rm (Rm < R),圆盘固定不动,硬 ...

  3. 2013长沙赛区现场赛 J - Josephina and RPG

    J - Josephina and RPG Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  4. ACM-ICPC 2017 西安赛区现场赛 K. LOVER II && LibreOJ#6062. 「2017 山东一轮集训 Day2」Pair(线段树)

    题目链接:西安:https://nanti.jisuanke.com/t/20759   (计蒜客的数据应该有误,题目和 LOJ 的大同小异,题解以 LOJ 为准)     LOJ:https://l ...

  5. 擦肩而过的那块牌--记ACM_ICPC西安赛区现场赛

    说了那么多次orz,这次是真的orz了.去了西安打区域赛,也想过会打铁.但当终于那一刻确定打铁了之后.心里还是非常不开心的,颁奖的时候思考熊那家伙嚣张的举起来手中那个金杯,说实话闪到我眼了(太亮了QA ...

  6. 2014 ACM/ICPC 鞍山赛区现场赛 D&amp;I 解题报告

    鞍山现场赛结束了呢-- 我们出的是D+E+I三道题-- 吾辈AC掉的是D和I两道,趁着还记得.先在这里写一写我写的两道水题D&I的解题报告吧^_^. D题的意思呢是说星云内有一堆排成一条直线的 ...

  7. ACM总结——2017ACM-ICPC北京赛区现场赛总结

    现在距离比赛结束已经过了一个多星期了,也是终于有时间写下心得了.回来就是被压着做项目,也是够够的. 这次比赛一样是我和两个学弟(虽然是学弟,但我的实力才是最弱的T_T)一起参加的,成绩的话打铁,算是情 ...

  8. 2013 ACM区域赛长沙 K Pocket Cube hdu 4801

    题意:给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(<=7)步内.最多能翻出几面相同的. 直接打表模拟每种翻转情况 #include<cstdio> #in ...

  9. ACM-ICPC 2018 青岛赛区现场赛 K. Airdrop && ZOJ 4068 (暴力)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4068 题意:吃鸡游戏简化为二维平面上有 n 个人 (xi,yi) ...

随机推荐

  1. [U3D 画起重机,绑脚本和控制它运动的基本操作]

    之前在学习Unity3D,不知为何网上的教学资源真是少啊...我某段时间还卡在不知如何让物体绑个脚本自动运动.. 之所以要学习U3D是因为导师让我做的IOS项目里有个需要模拟起重机,从而控制真实起重机 ...

  2. Oracle 应用于.NET平台

    1. 回顾ADO.NET ADO.NET是一组用于和数据源进行交互的面向对象类库集,它存在于.Net Framework中.通常情况下,数据源可以是各种类型的数据库,利用ADO.NET可以访问目前几乎 ...

  3. PTA fzu_oop_east

    GitHub链接: 传送门 5-1该日是该年的第几天 定义一个日期类Date,内有数据成员年.月.日,另有成员函数:构造函数用于初始化数据成员,输出,闰年的判断. 编写主函数:创建日期对象,计算并输出 ...

  4. 【Beta版本】冲刺-Day5

    队伍:606notconnected 会议时间:12月13日 目录 一.行与思 二.站立式会议图片 三.燃尽图 四.代码Check-in 一.行与思 张斯巍(433) 今日进展:继续修改界面及图标设计 ...

  5. Linux下安装py-leveldb

    1.下载源代码 svn checkout http://py-leveldb.googlecode.com/svn/trunk/ py-leveldb-read-only 2.安装辅助工具 sudo ...

  6. Linux DHCP通过OPTION43为H3C的AP下发AC地址

    对于DHCP服务,可以在很多平台上进行设置.那么这里我们就主要讲解一下在Linux DHCP服务器上通过option 43实现H3C的AP自动联系AC注册的相关内容.原来的DHCP Server是放在 ...

  7. Wavefront OBJ 转换成OpenGL ES使用的C/C++文件

    项目需要展示3D max模型,通过调研

  8. CF721C. Journey

    传送门 说实话,这是一道非常简单的DP题,简单到如果放到NOIp第二题可能都有些差强人意,然而我写崩了. 所以简单记录一下. 需要注意的是,这道题的DP应该是从$N$点开始,以1为边界,满足最短路的三 ...

  9. 解决centos7中python-pip模块不存在的问题

    centos 7中python-pip模块不存在,是因为像centos这类衍生的发行版,源跟新滞后,或者不存在.即使使用yum去search python-pip也找不到软件包. 为了使用安装滞后或源 ...

  10. 淘淘商城基于maven和svn的理解

    首先了解下maven和svn是什么: Maven是一个项目的管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目的生命周期(Project Life ...