清北学堂模拟赛d5t6 cube
2024-08-23 20:37:47
题面有误!10,11,12操作类别为A,13,14,15类别为B,16,17,18类别为C.
分析:一道大暴力,每次记录一下走了多少步,上一步操作类别是啥就可以了.最后只需要写6种操作,每一次操作进行4次就还原了,所以不用memcpy再来转.
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int n, ans[], cnt, c[];
bool stop = false; void turn1()
{
int tmp, tmp2;
tmp = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
tmp = c[];
tmp2 = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp2;
c[] = tmp;
} void turn2()
{
int tmp,tmp2;
tmp = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
tmp = c[];
tmp2 = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp2;
c[] = tmp;
} void turn3()
{
int tmp = c[], tmp2;
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
tmp = c[];
tmp2 = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
c[] = tmp2;
} void turn4()
{
int tmp = c[], tmp2;
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
tmp = c[];
tmp2 = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
c[] = tmp2;
} void turn5()
{
int tmp = c[], tmp2;
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
tmp = c[];
tmp2 = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp2;
c[] = tmp;
} void turn6()
{
int tmp = c[], tmp2;
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
tmp = c[];
tmp2 = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = c[];
c[] = tmp;
c[] = tmp2;
} bool check()
{
return c[] == c[] && c[] == c[] && c[] == c[] &&
c[] == c[] && c[] == c[] && c[] == c[] &&
c[] == c[] && c[] == c[] && c[] == c[] &&
c[] == c[] && c[] == c[] && c[] == c[] &&
c[] == c[] && c[] == c[] && c[] == c[] &&
c[] == c[] && c[] == c[] && c[] == c[];
} void dfs(int dep, int flag)
{
if (check())
{
cnt = dep;
stop = ;
return;
}
if (dep >= n)
return;
if (flag != )
{
for (int i = ; i <= ; i++)
{
turn1();
ans[dep + ] = i;
dfs(dep + , );
if (stop)
return;
}
turn1();
}
if (flag != )
{
for (int i = ; i <= ; i++)
{
turn2();
ans[dep + ] = + i;
dfs(dep + , );
if (stop)
return;
}
turn2();
}
if (flag != )
{
for (int i = ; i <= ; i++)
{
turn3();
ans[dep + ] = + i;
dfs(dep + , );
if (stop)
return;
}
turn3();
} if (flag != )
{
for (int i = ; i <= ; i++)
{
turn4();
ans[dep + ] = + i;
dfs(dep + , );
if (stop)
return;
}
turn4();
}
if (flag != )
{
for (int i = ; i <= ; i++)
{
turn5();
ans[dep + ] = + i;
dfs(dep + , );
if (stop)
return;
}
turn5();
}
if (flag != )
{
for (int i = ; i <= ; i++)
{
turn6();
ans[dep + ] = + i;
dfs(dep + , );
if (stop)
return;
}
turn6();
} } int main()
{
scanf("%d", &n);
for (int i = ; i <= ; i++)
scanf("%d", &c[i]);
dfs(, );
for (int i = ; i <= cnt; i++)
printf("%d ", ans[i]); return ;
}
最新文章
- JavaScript基础(一)之语法、变量、数据类型
- [转]jQuery: how to get which button was clicked upon form submission?
- 24单行插入与批量插入-insert(必学)-天轰穿sqlserver视频教程
- Lintcode: Remove Node in Binary Search Tree
- 数据字典 dba_free_space及相对文件号RELATIVE_FNO 小结
- JDBC数据库连接(MySQL为例)
- OpenRisc-52-run openrisc&;orpmon on ml501 board
- HttpClient(4.3.5) - 简单示例
- 问题:关于坛友的一个定时重复显示和隐藏div的实现
- tomcat热部署,更改java类不用重新加载context
- 输出不大于N的素数的个数
- 家中路由添加静态IP映射(二)
- alter 和 update的区别?
- Simditor 富文本编辑器多选图片上传、视频连接插入
- ES6 常用总结(前端开发js技术进阶提升总结)
- 20155332 2006-2007-2 《Java程序设计》第4周学习总结
- 01JAVA语言基础课后作业
- Java基础-IO流对象之字符类(FileWrite与FileReader)
- [Android UI] ActionBar 自定义属性
- C# 中使用 RSA加解密算法
热门文章
- 洛谷 P1498 南蛮图腾 —— 模拟
- LIBTOOL is undefined 问题的解决方法
- codeforces round #416 div2
- AcWing算法基础1.4
- 接口管理功能全面增强!EOLINKER EPC 5.0.9版本更新:支持LDAP用户系统、加入更多项目统计图表、强化测试/自动化测试功能等
- sql 全站搜索
- 【LeetCode】-- 260. Single Number III
- Spring boot中的定时任务(计划任务)
- 转 方法区(method) )、栈区(stack)和堆区(heap)之JVM 内存初学
- Android基于HttpUrlConnection类的文件下载