1.POJ2488  A Knight's Journey

search

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std; #define N 27
#define INF 0x7FFFFFFF
int p,q,_count=;
int _dec[N][N];
int routine[*N];
int t1,t2;
int flag,flag2; void path(int x,int y,int k)
{
switch (k)
{
case :{t1 = x-;t2 = y-;break;}
case :{t1 = x+;t2 = y-;break;}
case :{t1 = x-;t2 = y-;break;}
case :{t1 = x+;t2 = y-;break;}
case :{t1 = x-;t2 = y+;break;}
case :{t1 = x+;t2 = y+;break;}
case :{t1 = x-;t2 = y+;break;}
case :{t1 = x+;t2 = y+;break;}
}
}
void OUTPUT()
{
for (int i=;i<_count;i++)
{
cout<<(char)('A'+routine[*i+])<<routine[*i]+;
if (i==_count-) cout<<endl;
}
}
bool DFS(int x,int y)
{
if (flag2 == ) return ;
_dec[x][y]=;
routine[*_count]=x;
routine[*_count+]=y;
_count++;
if (_count>p*q)
{
flag2 = ;
return ;
}
if ((_count == p*q)&&(flag == ))
{
OUTPUT();
flag = ;
return ;
}
for (int k=;k<;k++)
{
path(x,y,k);
int xx=t1,yy = t2;
if ((xx>=)&&(xx<p)&&(yy>=)&&(yy<q)&&(_dec[xx][yy]==))
if (DFS(xx,yy)) return ;
}
_dec[x][y]=;
_count--;
return ;
}
int main()
{
int n;
cin>>n;
for (int m=;m<=n;m++)
{
for (int i=;i<N;i++)
for (int j=;j<N;j++)
_dec[i][j]=;
memset(routine,,sizeof(routine));
cin>>p>>q;
cout<<"Scenario #"<<m<<":"<<endl;
if ((p==)&&(q==))
{
cout<<"A1"<<endl<<endl;
continue;
}
if (p*q> || p>= || q>= || p<= || q<=)
{
cout<<"impossible"<<endl<<endl;
continue;
}
_count = ;
flag = ;
flag2 = ;
DFS(,);
if ((flag2 == )||(flag==)) cout<<"impossible"<<endl;
cout<<endl;
}
return ;
}

2.POJ 1077 Eight

http://blog.csdn.net/whyorwhnt/article/details/10555989

Union Find and search的更多相关文章

  1. Vue + GraphQL初试

    基本用法 GraphQL概述 GraphQL基本语法特性 GraphQL类型系统 GraphQL类型系统内置基础类型 GraphQL类型系统内置修饰符 GraphQL工作原理 GraphQL执行过程 ...

  2. Search Quick Union Find(图的存储结构)

    Quick Find:适用于search频繁的情况 每个节点有一个id值,id相同表示两个节点相连通.在union时要将等于某一个id值都改成另一个id值 Quick Union: 适用于union频 ...

  3. ecshop /search.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP商城系统Search.php页面过滤不严导致SQL注入漏洞 ...

  4. dedecms /plus/search.php SQL Injection && Local Variable Overriding

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 这个文件有两处注入漏洞 . $typeid变量覆盖导致ChannelTy ...

  5. 集成 Union Pay - 银联支付

    作者感言 前面已经把WeChat SDK的支付, AliPay SDK搞得七七八八了, 接下来就是银联支付的Union Pay SDK.最后:如果你有更好的建议或者对这篇文章有不满的地方, 请联系我, ...

  6. 论文阅读笔记四十七:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression(CVPR2019)

    论文原址:https://arxiv.org/pdf/1902.09630.pdf github:https://github.com/generalized-iou 摘要 在目标检测的评测体系中,I ...

  7. [IR] XPath for Search Query

    XPath 1.0 XPath Containment Distributed Query Evaluation RE and DFA XPath 1.0 -- 在XML中的使用 XPath 语法: ...

  8. bWAPP练习--injection篇SQL Injection (GET/Search)

    SQL注入: SQL注入,就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.具体来说,它是利用现有应用程序,将(恶意)的SQL命令注入到 ...

  9. Union比or快 Using UNION is faster when it comes to cases like scan two different column。

    problem: 595. Big Countries A country is big if it has an area of bigger than 3 million square km or ...

随机推荐

  1. GridView块布局

    <GridView android:id="@+id/gridview" android:layout_width="match_parent" andr ...

  2. 在js里面使用php语言

  3. Android 用adb pull或push 拷贝手机文件到到电脑上,拷贝手机数据库到电脑上,拷贝电脑数据库到手机上

    先说一下adb命令配置,如果遇到adb不是内部或外部命令,也不是可运行的程序或批量文件.配置下环境变量 1.adb不是内部或外部命令,也不是可运行的程序或批量文件. 解决办法:在我的电脑-属性-高级计 ...

  4. [MySQL]导入导出

    [MySQL]导入导出 一 导入文本数据 1)mysql->load data infile 数据文件c:/mytable.txt 如下:(每一行为一条记录,记录的字段间用tab隔开,最后一个字 ...

  5. elk是指logstash,elasticsearch,kibana三件套,这三件套可以组成日志分析和监控工具

    Logstash是一个完全开源的工具,他可以对你的日志进行收集.分析,并将其存储供以后使用(如,搜索),您可以使用它.说到搜索,logstash带有一个web界面,搜索和展示所有日志.kibana 也 ...

  6. 2016.6.17 kali Linux 隧道工具

    隧道工具的基本概念: 1.在计算机网络中,隧道工具是指使用一种网络协议去封装另一种网络协议的技术. 2.通常用来数据伪装或者穿越防火墙,在入侵目标系统后,可用来提升权限和权限维持. Kali中的隧道工 ...

  7. c#知识总结1

    一.C#程序结构 一个c#程序主要包括以下部分 ①命名空间声明 ②一个class ③class方法 ④class属性 ⑤一个main方法 ⑥语句 和 表达式 以及 注释 简单的“Helloworld” ...

  8. bug 调试了一个下午外加半个晚上的bug

    public void queryTaskResult2() throws Exception { HttpServletRequest request = ServletActionContext. ...

  9. 【BZOJ】3850: ZCC Loves Codefires(300T就这样献给了水题TAT)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3850 题意:类似国王游戏....无意义.. #include <cstdio> #inc ...

  10. Chromium的UI绘制初探

    转载请注明出处:http://www.cnblogs.com/fangkm/p/3943896.html 常见的UI库的绘制逻辑 任何一个成熟的界面框架都有一个相当复杂的结构,消息循环的处理.控件的布 ...