/*
模拟;
注意:实质上一次魔方的一半要变化
用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. KMS算法

    解题:http://hihocoder.com/problemset/problem/1015 KMP算法是一种改进的字符串匹配算法,由D.E.Knuth,J.H.Morris和V.R.Pratt同时 ...

  2. iOS开发-Runtime详解

    iOS开发-Runtime详解 简介 Runtime 又叫运行时,是一套底层的 C 语言 API,其为 iOS 内部的核心之一,我们平时编写的 OC 代码,底层都是基于它来实现的.比如: [recei ...

  3. SQLite – ORDER 子句

    SQLite - ORDER BY子句 The SQLite ORDER BY子句用于数据按升序或降序排序,基于一个或多个列. 语法: ORDER BY子句的基本语法如下: SELECT column ...

  4. iOS端架构、基本组成与使用说明

    一. app整体描述 app的描述:需求文档+接口文档+程序架构. 说明:新入手的开发人员必须拿到这三个说明文档才能整体了解app功能. 二.app架构描述 1.架构视图 2.分层结构说明 [1] a ...

  5. 众皓网络(T 面试)

    1.你们项目中哪里用到了Redis? 2.Redis中存储的数据,你们什么时候进行更新? 3.你用过消息队列吗? 4.你写的这个微服务项目拆分成了几个服务? 5.SpringCloud项目怎么部署的?

  6. 细说PHP-5.4 变量的类型

    变量类型是指保存在该变量中的数据类型.计算机操作的对象是数据在计算编程语言世界里,每一个数据也都有它的类型,具有相同类型的数据才能彼此操作.例如书柜是装书用的.大衣柜是放衣服用的.保险柜是存放贵重物品 ...

  7. json-server && axios

    json-server && axios vue2.0项目实战(3)使用axios发送请求 https://www.cnblogs.com/zhouyangla/p/6753673.h ...

  8. MFC (Combo-box control)下拉列表控件的使用

    1.可以选择,但无法编辑状态: 选择下拉框的属性中的类型(Type)参数——Drop List; 2.如何控制Combo Box的下拉长度 1,一.在资源文件中打开对话框,选中Combo Box控件, ...

  9. 测试常用的linux命令

    一.系统 1.halt:         关机   poweroff: 关机 2.reboot:     重启 二.处理目录和文件的命令 1.ll:     显示文件详细信息 ls:    显示文件目 ...

  10. PHP17 PDO

    学习要点 PDO简要 PDO对象 PDO对象的使用 PDOStatement对象 PDO事务处理 PDO简要 PHP支持那些数据库操作 MySQL,Oracle,SQLServer,SQLite.Po ...