惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - xmx

Amazon 2面杯具 N皇后回溯 "中航文化杯" 2007 ACM/ICPC 国际大学生程序设计竞赛亚洲区域赛(南京) pku 1662 还是找规律的 pku 1806 Manhattan 2025(找规律) 今天西华的比赛,啥都不说啦,相当的nice!~~~ 今天北京赛区的比赛 pku 1505 copying books(DP) 最近看的一些东西 The 2007 ACM Asia Programming Contest Changchun Site Internet Preliminary Contest nice 位运算果真是好东西,今天算是学到点啦^_^ FOJ月赛-2007年9月 pku 1850 前面一直没注意到某个不规范的情况,导致结果一直比标准的大...调了好久... 终于有算最长重复子串(数)的后缀数组啦,nice The 2007 ACM Asia Programming Contest - Nanjing Preliminary pku 3219 人家居然用几十B就过了,肯定有超强的规律,可是我自己找了个,挂了...只能老实算... 一道双向dp,差点超时^_^||| dp pku 1050 N和素数P,求杨辉三角第N行中能被P整除的数的个数
一个用来练dfs的简单迷宫问题
xmx · 2007-10-20 · via 博客园 - xmx

#include <stdio.h>
#include <string.h>
using namespace std;

int i,t,n,m,k;
int x1,x2,y1,y2;
char p[110][110];
short turn[110][110];

bool dfs(int x,int y,int t,int d)
{
    int tx,ty,tt,td,i,j;
    bool flag;
   
    if(x<0 || x>=n || y<0 || y>=m)
        return false;
    if(t > turn[x][y] || t > k)    return false;
    else    turn[x][y] = t;
   
    if(t == k)
        if(x!=x2-1 && y!=y2-1)
            return false;

    if(x==x2-1 && y==y2-1)    return true;
   
    for(i=0;i<4;i++)
    {
        if(i==2)    continue;
        td = (d+i) % 4;
        tt = t + i%2;
        switch(td)
        {
        case 0:
            tx = x-1;
            ty = y;
            break;
        case 1:
            tx = x;
            ty = y+1;
            break;
        case 2:
            tx = x+1;
            ty = y;
            break;
        case 3:
            tx = x;
            ty = y-1;
            break;
        }
       
        if(p[tx][ty] == '.')
        {
            p[tx][ty] = '*';
            if( dfs(tx,ty,tt,td) )
            {
                p[tx][ty]  = '.';
                return true;
            }
            p[tx][ty]  = '.';
        }
    }
    return false;
}

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&n,&m);
        getchar();
        for(i=0;i<n;i++)
            gets(p[i]);
        scanf("%d %d %d %d %d",&k,&y1,&x1,&y2,&x2);
        memset(turn,127,sizeof(turn));
        for(i=0;i<4;i++)
        {
            p[x1-1][y1-1] = '*';
            if( dfs(x1-1,y1-1,0,i) )
                break;
        }
        if(i==4)    printf("no\n");
        else    printf("yes\n");
    }
}