1008 Gnome Tetravex
练习使用DPS的题,不知道有无别的做法,思路不复杂。形式是统计并且进行数字配对。
#include <stdio.h>
][],note[],ans[];
void ini(){
int i,j,top,right,bottom,left;
;i<;i++){
;j<;j++)
sub[i][j]=;
note[i]=;
ans[i]=;
}
m=;
f=n*n;
;i<f;i++){
scanf("%d %d %d %d",&top,&right,&bottom,&left);
;j<m;j++){
]==top&&sub[j][]==right&&sub[j][]==bottom&&sub[j][]==left){
note[j]++;
break;
}
}
if(j==m){
sub[m][]=top;
sub[m][]=right;
sub[m][]=bottom;
sub[m][]=left;
note[m]=;
m++;
}
}
}
int DPS(int pos){
if(pos==f)
;
else{
int i;
;i<m;i++){
if(note[i]){
if(pos>=n)
]!=sub[i][])
continue;
)
]][]!=sub[i][])
continue;
note[i]--;
ans[pos]=i;
))
;
note[i]++;
}
}
}
;
}
int main(){
;
){
scanf("%d",&n);
if(!n)
break;
ini();
)
printf("\n");
printf("Game %d: ",index++);
))
printf("Possible\n");
else
printf("Impossible\n");
}
;
}
1008 Gnome Tetravex的更多相关文章
- ZOJ 1008 Gnome Tetravex(DFS)
Gnome Tetravex Time Limit: 10 Seconds Memory Limit: 32768 KB Hart is engaged in playing an inte ...
- [ZOJ 1008]Gnome Tetravex (dfs搜索 + 小优化)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目大意:给你n*n的矩阵,每个格子里有4个三角形,分别是 ...
- ZOJ 1008 Gnome Tetravex(DFS)
题目链接 题意 : 将n*n个正方形进行排列,需要判断相邻的正方形的相邻三角形上边的数字是不是都相等. 思路 : 只知道是个深搜,一开始不知道怎么搜,后来看了题解才明白,就是说不是自己去搜,而是将给定 ...
- zoj 1008 Gnome Tetravex
开放式存储阵列为每平方米有几个,否则,超时-- #include <stdio.h> #include <string.h> #include <iostream> ...
- Gnome Tetravex
zoj1008:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目意思是有一个游戏,即给出一个图,该图是由n*n个 ...
- ZOJ1008 Gnome Tetravex
DFS+剪枝~ #include<bits/stdc++.h> using namespace std; ][]; int N; int cnt; ]; ]; unordered_map& ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- HDOJ 1008. Elevator 简单模拟水题
Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
随机推荐
- a标签href不跳转 禁止跳转
a标签href不跳转 禁止跳转 当页面中a标签不需要任何跳转时,从原理上来讲,可分如下两种方法: 标签属性href,使其指向空或不返回任何内容.如: <a href="javascri ...
- TypeScript开发Vue
用TypeScript开发Vue——如何通过vue实例化对象访问实际ViewModel对象 目录 背景 解决方案 关于Vue中的计算属性类型 TypeScript的强制类型声明语法 强制类型声明的局限 ...
- centos 源码安装git
(1) 添加rpmforge源 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686 ...
- iOS 断网处理
iOS 断网处理 (2014-01-13 18:13:21) 转载▼ 标签: it - (BOOL)application:(UIApplication *)application didFini ...
- eclipse安装github插件egit
http://jingyan.baidu.com/article/4853e1e529483c1909f726c3.html help->InstallNew Software,这是安装插件推荐 ...
- LeetCode_implement strstr ()
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if need ...
- 试用mysql的infobright引擎
海量数据分析处理,向来比较头疼费劲,特别是项目资金不允许的情况下,都是优先考虑开源软件,2007使用mysql,2009年尝试greenplum(公司最终选用oracle),20 ...
- hihoCoder 1092 : Have Lunch Together
题目大意:小hi和小ho去咖啡厅喝咖啡,咖啡厅可以看作是n * m的矩阵,每个点要么为空,要么被人.障碍物.椅子所占据,小hi和小ho想要找两个相邻的椅子.起初两个人都在同一个点,求两人到达满足要求的 ...
- LINQ to SQL 增,删,改
添加 InsertOnSubmit(单个对象) 或 InsertAllOnSubmit(集合) 删除 DeleteOnSubmit (单个对象) DeleteAll ...
- python list 去重
print u'列表去重'a=[1,2,3,3,2,1,4,4,5,6,'a','a','b','c']print list(set(a))