poj-3050-Hopscotch
来源:互联网 发布:淘宝主图视频内存大小 编辑:程序博客网 时间:2024/06/14 20:35
题意:0-
思路:直接暴力枚举所有状态,不多说,但我刚写的时候开了个全局的1e6的数组来判断是否重复出现,一直运行错误,很不解。
后面用set替换了这个数组,set还能去重很方便。
代码附上:
#include <cstdio>#include <cstring>#include <cctype>#include <iostream>#include <queue>#include <set>#include <cmath>#include <algorithm>#define FIN freopen("input.txt","r",stdin)using namespace std;typedef long long ll;typedef pair<int,int>P;const int MAX = 1000005;const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};int maze[20][20];int tot;set<int>setnum;void dfs(int x,int y,int cnt,int res){ if(cnt==5){setnum.insert(res);return ;} for(int i=0;i<4;i++){ int nx=x+dx[i]; int ny=y+dy[i]; if(0<=nx&&nx<5&&ny>=0&&ny<5){ dfs(nx,ny,cnt+1,res*10+maze[nx][ny]); } }}int main(){ //FIN; for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ scanf("%d",&maze[i][j]); } } tot=0; for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ dfs(i,j,0,maze[i][j]); } } printf("%d\n",setnum.size()); return 0;}
0 0
- POJ 3050 Hopscotch
- poj 3050 Hopscotch DFS
- poj 3050 Hopscotch
- POJ-3050-Hopscotch
- poj 3050 Hopscotch
- POJ 3050 Hopscotch 水~
- POJ 3050 Hopscotch
- POJ-3050 Hopscotch
- POJ 3050 Hopscotch DFS
- POJ 3050 Hopscotch
- POJ 3050 Hopscotch
- poj 3050 Hopscotch 【DFS】
- poj 3050 Hopscotch
- Hopscotch (poj 3050 dfs)
- POJ 3050 Hopscotch
- Hopscotch.(POJ-3050)
- Hopscotch - POJ 3050 DFS
- POJ 3050 Hopscotch
- Spring JDBCの紹介
- 牛腩新闻发布系统——静态方法使用问题(Static)
- 338. Counting Bits
- Process, program, thread 的区别
- Vector 线程安全与不安全
- poj-3050-Hopscotch
- 【办公采购系统】系统中遇到的问题汇总(一)——模板页使用
- oj数据结构题谜之输出格式
- 华为老总推荐的文章
- googletest mock设置 编译器选项 vs下
- 搜索算法11之1016
- Shiro入门
- 如何在未知链表中找到一个中间节点
- 异步选择WSAAsyncSelect