/*
模拟;
注意:实质上一次魔方的一半要变化
用c++超内存
用g++过了
*/
#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
struct node
{
int f0[4],f4[4],f6[4],f8[4],f16[4],f20[4];
int step;
} s,next;
int fnow[10000][6];
int kk(int f[4])
{
if(f[0]==f[1]&&f[1]==f[2]&&f[2]==f[3])
return 1;
return 0;
}
int comp(struct node ss)//计算有几个面是同色
{
int sum=0;
sum+=kk(ss.f0);
sum+=kk(ss.f4);
sum+=kk(ss.f6);
sum+=kk(ss.f8);
sum+=kk(ss.f16);
sum+=kk(ss.f20);
return sum;
}
void clock(int f[4],int fd[4])//顺时针旋转
{
f[0]=fd[2];
f[2]=fd[3];
f[3]=fd[1];
f[1]=fd[0];
return ;
}
void clockfan(int f[4],int fd[4])//逆时针旋转
{
f[0]=fd[1];
f[1]=fd[3];
f[3]=fd[2];
f[2]=fd[0];
return ;
}
void Switch(struct node s,int k)//6种旋转方式
{
if(k==0)
{
next.f0[0]=s.f20[0];
next.f0[2]=s.f20[2];
next.f6[0]=s.f0[0];
next.f6[2]=s.f0[2];
next.f16[0]=s.f6[0];
next.f16[2]=s.f6[2];
next.f20[0]=s.f16[0];
next.f20[2]=s.f16[2];
clock(next.f4,s.f4);//要变化
}
if(k==1)
{
next.f20[0]=s.f0[0];
next.f20[2]=s.f0[2];
next.f0[0]=s.f6[0];
next.f0[2]=s.f6[2];
next.f6[0]=s.f16[0];
next.f6[2]=s.f16[2];
next.f16[0]=s.f20[0];
next.f16[2]=s.f20[2];
clockfan(next.f4,s.f4);//要变化
}
if(k==2)
{
next.f4[0]=s.f6[0];
next.f4[1]=s.f6[1];
next.f20[2]=s.f4[1];
next.f20[3]=s.f4[0];
next.f8[0]=s.f20[3];
next.f8[1]=s.f20[2];
next.f6[0]=s.f8[0];
next.f6[1]=s.f8[1];
clock(next.f0,s.f0);
}
if(k==3)
{
next.f6[0]=s.f4[0];
next.f6[1]=s.f4[1];
next.f4[0]=s.f20[3];
next.f4[1]=s.f20[2];
next.f20[3]=s.f8[0];
next.f20[2]=s.f8[1];
next.f8[0]=s.f6[0];
next.f8[1]=s.f6[1];
clockfan(next.f0,s.f0);
}
if(k==4)
{
next.f0[2]=s.f8[0];
next.f0[3]=s.f8[2];
next.f4[1]=s.f0[3];
next.f4[3]=s.f0[2];
next.f16[0]=s.f4[1];
next.f16[1]=s.f4[3];
next.f8[0]=s.f16[1];
next.f8[2]=s.f16[0];
clockfan(next.f6,s.f6);
}
if(k==5)
{
next.f8[0]=s.f0[2];
next.f8[2]=s.f0[3];
next.f0[3]=s.f4[1];
next.f0[2]=s.f4[3];
next.f4[1]=s.f16[0];
next.f4[3]=s.f16[1];
next.f16[1]=s.f8[0];
next.f16[0]=s.f8[2];
clock(next.f6,s.f6);
}
}
int n,len;
void chh(int &f,int fd[4])
{
f=fd[3];
f=f*6+fd[2];
f=f*6+fd[1];
f=f*6+fd[0];
return ;
}
void fswitch(struct node s,int kf[6])
{
chh(kf[0],s.f0);
chh(kf[1],s.f4);
chh(kf[2],s.f6);
chh(kf[3],s.f8);
chh(kf[4],s.f16);
chh(kf[5],s.f20);
return ;
}
void bfs(struct node s)
{
int j,k,maxx;
struct node cur;
maxx=comp(s);
s.step=0;
len=0;
queue<node>q;
q.push(s);
while(!q.empty())
{
cur=q.front();
q.pop();
if(cur.step>=n)continue;
for(k=0; k<6; k++)
{
next=cur;
Switch(cur,k);
j=comp(next);
next.step++;
q.push(next);
if(j>maxx)
maxx=j;
if(maxx==6)break;
}
if(maxx==6)break;
}
printf("%d\n",maxx);
return ;
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
scanf("%d%d%d%d",&s.f0[0],&s.f0[1],&s.f0[2],&s.f0[3]);
scanf("%d%d%d%d",&s.f4[0],&s.f4[1],&s.f6[0],&s.f6[1]);
scanf("%d%d%d%d",&s.f8[0],&s.f8[1],&s.f4[2],&s.f4[3]);
scanf("%d%d%d%d",&s.f6[2],&s.f6[3],&s.f8[2],&s.f8[3]);
scanf("%d%d%d%d",&s.f16[0],&s.f16[1],&s.f16[2],&s.f16[3]);
scanf("%d%d%d%d",&s.f20[0],&s.f20[1],&s.f20[2],&s.f20[3]);
bfs(s);
}
return 0;
}

hdu 4801模拟题的更多相关文章

  1. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  2. HDU 4452 Running Rabbits (模拟题)

    题意: 有两只兔子,一只在左上角,一只在右上角,两只兔子有自己的移动速度(每小时),和初始移动方向. 现在有3种可能让他们转向:撞墙:移动过程中撞墙,掉头走未完成的路. 相碰: 两只兔子在K点整(即处 ...

  3. hdu 5641 King's Phone(暴力模拟题)

    Problem Description In a military parade, the King sees lots of new things, including an Andriod Pho ...

  4. HDU 1262 寻找素数对 模拟题

    题目描述:输入一个偶数,判断这个偶数可以由哪两个差值最小的素数相加,输出这两个素数. 题目分析:模拟题,注意的是为了提高效率,在逐个进行判断时,只要从2判断到n/2就可以了,并且最好用打表法判断素数. ...

  5. HDU 2093 考试排名 模拟题

    解题报告: 题目描述:写一个程序给一个编程考试C++实时提交系统排名,给你的数据是题目的总数,每次错误提交罚的时间分,每位用户的姓名,然后是输入用户每题的完成情况,有一下几种情况,第一,输入只有一个正 ...

  6. hdu 4706:Children's Day(模拟题,模拟输出大写字母 N)

    Children's Day Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  7. HDU 2414 Chessboard Dance(模拟题,仅此纪念我的堕落)

    题目 模拟题也各种wa,我最近真的堕落了,,,,,智商越来越为负数了!!!!!!!! #include<stdio.h> #include<string.h> #include ...

  8. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  9. poj 1888 Crossword Answers 模拟题

    Crossword Answers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 869   Accepted: 405 D ...

随机推荐

  1. ios学习笔记 UITableView(纯代码) (二)

    头文件 --------------------------------------------- #import <UIKit/UIKit.h> /** UITableViewDataS ...

  2. Log4net系列一:Log4net搭建之文本格式输出

    Log4net简介 前言 项目开发中,记录项目日志是必须的,如果非要说日志的重要性(日志可看做,飞机的黑匣子,或者汽车的行车记录仪),根据等级进行记录,方便我们排查相关问题,以后项目运维中,也方便很多 ...

  3. macOS 的 JDK 安装问题 (Homebrew)

    Homebrew 介绍 Homebrew 是 macOS 下的一个非常好用的包管理工具, caskroom 则是基于 Homebrew 构建的一个强大的应用程序管理器. 具体用法可以餐参考 像 Mac ...

  4. React-Native 开发问题整理

    1.内嵌WebView,点击输入框后页面不自动上滚 <activity android:name=".MainActivity" android:label="@s ...

  5. HttpServletResponse 的状态码

    public static final int  SC_ACCEPTED  202 public static final int  SC_BAD_GATEWAY  502 public static ...

  6. laravel权限控制Gate

    实现思想 注册 位置: app/Providers/AuthServiceProvider.php $permissions = \App\AdminPermission::all(); foreac ...

  7. android开发中设置字体

    转自:http://segmentfault.com/q/1010000000494116 http://ryanhoo.github.io/blog/2014/05/05/android-bette ...

  8. MYSQL 二次筛选,统计,最大值,最小值,分组,靠拢

    HAVING 筛选后再 筛选 SELECT CLASS,SUM(TOTAL_SCORES) FROM student_score GROUP BY CLASS HAVING SUM(TOTAL_SCO ...

  9. 洛谷 P1361 小猫爬山

    题目描述 WD和LHX饲养了N只小猫,这天,小猫们要去爬山.经历了千辛万苦,小猫们终于爬上了山顶,但是疲倦的它们再也不想徒步走下山了. WD和LHX只好花钱让它们坐索道下山.索道上的缆车最大承重量为W ...

  10. Zend Studio 修改“代码字体和大小”