练习使用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的更多相关文章

  1. ZOJ 1008 Gnome Tetravex(DFS)

    Gnome Tetravex Time Limit: 10 Seconds      Memory Limit: 32768 KB Hart is engaged in playing an inte ...

  2. [ZOJ 1008]Gnome Tetravex (dfs搜索 + 小优化)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目大意:给你n*n的矩阵,每个格子里有4个三角形,分别是 ...

  3. ZOJ 1008 Gnome Tetravex(DFS)

    题目链接 题意 : 将n*n个正方形进行排列,需要判断相邻的正方形的相邻三角形上边的数字是不是都相等. 思路 : 只知道是个深搜,一开始不知道怎么搜,后来看了题解才明白,就是说不是自己去搜,而是将给定 ...

  4. zoj 1008 Gnome Tetravex

    开放式存储阵列为每平方米有几个,否则,超时-- #include <stdio.h> #include <string.h> #include <iostream> ...

  5. Gnome Tetravex

    zoj1008:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目意思是有一个游戏,即给出一个图,该图是由n*n个 ...

  6. ZOJ1008 Gnome Tetravex

    DFS+剪枝~ #include<bits/stdc++.h> using namespace std; ][]; int N; int cnt; ]; ]; unordered_map& ...

  7. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  8. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  9. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

随机推荐

  1. Xshell4连接Linux后 win快捷键锁屏

    今天在使用Xshell连接CentOS后 使用Vim编辑器编辑完后 习惯性的按了Ctrl+S 然后按什么都不起作用 只能重新连接 通过查资料得知 Ctrl + S 是Linux 锁屏的快捷键 要解除锁 ...

  2. Cstring获取第N个字符

    void CTestaDlg::GetCStringItemAt(CString strin,CString & strout,int nindex) { ); ; ]={'\0'}; whi ...

  3. LeetCode_Simplify Path

    Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", ...

  4. How to find friends

    How to find friends 思路简单,编码不易 1 def check_connection(network, first, second): 2 link_dictionary = di ...

  5. shell 中如何判断前一个命令是否执行成功

    shell 中如何判断前一个命令是否执行成功 通过判断返回值来解决: if [ $? -eq 0 ];then 命令正确的分支 else   命令失败的分支 fi

  6. UML--一些图

    通过UML来表示汽车,简洁明了. 统一建模语言--UML. 参与者Actor,参与者代表了现实世界的人.人. 用例use case,就是参与者要做什么并且获得什么.事. 业务场景,用例场景.规则. 业 ...

  7. 重载operator new实现检测内存泄漏是否可行

    行与不行,就凭我这水平,说出来未免显示太过自大.不还,我还想根据自己的代码来讨论这个问题. 重载operator new来检测内存只的办法,那就是在new的时候记录指针地址及文件名.行号,在delet ...

  8. bootstrap 兼容IE8设置

    <!--[if lt IE 9]> <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js" ...

  9. Python 异步IO、IO多路复用

    事件驱动模型 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  10. pyqt最小化学习

    # -*- coding: cp936 -*- #!/usr/bin/env python # -*- coding:utf-8 -*- from PyQt4 import QtCore, QtGui ...