hdu 4801模拟题
/*
模拟;
注意:实质上一次魔方的一半要变化
用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模拟题的更多相关文章
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- HDU 4452 Running Rabbits (模拟题)
题意: 有两只兔子,一只在左上角,一只在右上角,两只兔子有自己的移动速度(每小时),和初始移动方向. 现在有3种可能让他们转向:撞墙:移动过程中撞墙,掉头走未完成的路. 相碰: 两只兔子在K点整(即处 ...
- hdu 5641 King's Phone(暴力模拟题)
Problem Description In a military parade, the King sees lots of new things, including an Andriod Pho ...
- HDU 1262 寻找素数对 模拟题
题目描述:输入一个偶数,判断这个偶数可以由哪两个差值最小的素数相加,输出这两个素数. 题目分析:模拟题,注意的是为了提高效率,在逐个进行判断时,只要从2判断到n/2就可以了,并且最好用打表法判断素数. ...
- HDU 2093 考试排名 模拟题
解题报告: 题目描述:写一个程序给一个编程考试C++实时提交系统排名,给你的数据是题目的总数,每次错误提交罚的时间分,每位用户的姓名,然后是输入用户每题的完成情况,有一下几种情况,第一,输入只有一个正 ...
- hdu 4706:Children's Day(模拟题,模拟输出大写字母 N)
Children's Day Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- HDU 2414 Chessboard Dance(模拟题,仅此纪念我的堕落)
题目 模拟题也各种wa,我最近真的堕落了,,,,,智商越来越为负数了!!!!!!!! #include<stdio.h> #include<string.h> #include ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
- poj 1888 Crossword Answers 模拟题
Crossword Answers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 869 Accepted: 405 D ...
随机推荐
- Tcl介绍和基础语法
Tcl的背景 Tcl(读作tickle)诞生于80年代的加州大学伯克利分校,作为一种简单高效可移植性好的脚本语言,目前已经广泛应用在几乎所有的EDA工具中.Tcl 的最大特点就是其语法格式极其简单,采 ...
- CMSIS的简介
Cortex微控制器软件接口标准(Cortex Microcontroller Software Interface Standard)是ARM和一些编译器厂家以及半导体厂家共同遵循的一套标准,是由A ...
- Linux环境下手动配置sbt
一.下载sbt安装包 从sbt官网下载地址:http://www.scala-sbt.org/download.html下载安装包,以sbt-0.13.13.tgz为例. 二.安装 1.将下载的二进制 ...
- Android(java)学习笔记155:中文乱码的问题处理(qq登录案例)
1. 我们在之前的笔记中LoginServlet.java中,我们Tomcat服务器回复给客户端的数据是英文的"Login Success","Login Failed& ...
- execl, execlp, execle, execv, execvp - 执行某个文件
总览 (SYNOPSIS) #include <unistd.h> extern char **environ; int execl( const char *path, const ch ...
- 第三周:Excel
一.Excel的常见函数: 1.文本清洗函数: https://ask.hellobi.com/blog/cbdingchebao/10149
- 2012 noip提高 Vigenère 密码
P1079 Vigenère 密码 题目描述 16 世纪法国外交家 Blaise de VigenèreBlaisedeVigene`re 设计了一种多表密码加密算法―― VigenèreVigene ...
- thinkphp5 自定义验证码使用
控制器[https://blog.csdn.net/John_rush/article/details/80169702] public function verify(){ $captcha = n ...
- 文本三剑客之sed
sed是一个流编辑器(sed是stream editor的缩写),它可以对从标准输入流中得到的数据进行处理,然后把处理以后得到的结果输出到标准输出,而标准输出通常会关联到终端屏幕,因此处理后的结果也会 ...
- java多线程之ForkJoinPool
转https://www.cnblogs.com/lixuwu/p/7979480.html 阅读目录 使用 背景:ForkJoinPool的优势在于,可以充分利用多cpu,多核cpu的优势,把一个任 ...