/*
模拟;
注意:实质上一次魔方的一半要变化
用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. 【学习笔记】深入理解js原型和闭包(1)—— 一切都是对象

    “一切都是对象”这句话的重点在于如何去理解“对象”这个概念. ——当然,也不是所有的都是对象,值类型就不是对象. 首先咱们还是先看看javascript中一个常用的运算符——typeof.typeof ...

  2. IOS访问webserver接口

    接口调用参数只能是字符串格式,返回格式支持3种(字符串,数组,DataSet) 需要引用第三方库,包含(DataSet,PlatServinceDataParser,WebserviceCommon, ...

  3. C# 调用第三方DLL缓冲区溢出导致的异常

    这个倒是少见的错误,纪录一下大佬. 先上异常 错误一:尝试读取或写入受保护的内存 错误二:未将对象引用设置到对象的实例 错误三:  托管调试助手“FatalExecutionEngineError”( ...

  4. 错误:Implicit super constructor xx() is undefined for default constructor.

    因为父类定义了一个有参的构造函数且父类中没有默认的无参构造方法,此时编译器不会为你调用默认的构造函数,当子类继承时,必须在自己的构造函数显式调用父类的构造函数,才能确保子类在初始化前父类会被实例化,如 ...

  5. vue+element ui项目总结点(一)select、Cascader级联选择器、encodeURI、decodeURI转码解码、mockjs用法、路由懒加载三种方式

    不多说上代码: <template> <div class="hello"> <h1>{{ msg }}</h1> <p> ...

  6. HDU 5410 CRB and His Birthday (01背包,完全背包,混合)

    题意:有n种商品,每种商品中有a个糖果,如果买这种商品就送多b个糖果,只有第一次买的时候才送.现在有m元,最多能买多少糖果? 思路:第一次买一种商品时有送糖果,对这一次进行一次01背包,也就是只能买一 ...

  7. DBMS数据库语言

    https://www.yiibai.com/dbms/dbms-language.html DBMS具有适当的语言和接口来表达数据库查询和更新.数据库语言可用于读取,存储和更新数据库中的数据. 数据 ...

  8. 汇编3栈帧,参数传递,串操作,混合汇编,x64,asm文件

    基础知识2 选择结构 通过判断 + 条件跳转指令来实现 循环结构 通过判断 + 条件跳转指令来实现(会有一个向上跳转的语句) 函数调用约定 C调用约定: 由外部平衡栈 标准调用约定 : 由函数内部平衡 ...

  9. Web前端基础怎么学? JavaScript、html、css知识架构图

    以前开发者只要掌握 HTML.CSS.JavaScript 三驾马车就能胜任一份前端的工作了.而现在除了普通的编码以外,还要考虑如何性能优化,如何跨端.跨平台实现功能,尤其是 AI.5G 技术的来临, ...

  10. JDK 5 ~ 11 新特性倾情整理

    为了大家对JDK有一个全面的了解,下面我为大家整理了JDK5~11的所有关键新特性! 先看一下JDK的版本迭代图: 注:   OpenJDK和JDK区别  GPL协议通用性公开许可证(General ...