Codeforces Round #212 (Div. 2) A A. Two Semiknights Meet

做一个高素质选手实在太难奥林匹克精神绝对不止止是体育在紧张的时候冷静下来读题分析真的挺重要的这个题目其实很简单。当然要求你有很强的编码经验和调试经验,题意还是有点坑爹的,这种棋盘搜索的题意都是有点坑爹的,#这种石头就是打酱油的,你可以吐槽出题人,但永远不会改变你wa的事实。还有注意是同时移动的。加油吧。
/*
    author:ray007great
    version:1.0
*/
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
/*  define */

#define sf(a) scanf("%d",&a)
#define sfs(a) scanf("%s",a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define rep1(i,a,b) for(int i=(a);i<(b);i++)
#define clr(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
#define pfk  printf("fuck\n")

/*  define */
int dx[]={2,2,-2,-2};
int dy[]={2,-2,2,-2};
int f;
bool vis1[25][25];
bool vis2[25][25];
char m[25][25];
int desx,desy,flag;
void dfs(int x1,int y1,int x2,int y2){
    if(x1==x2 && y1==y2) {flag=1;return;}
    if(flag) return ;
    for(int i=0;i<4;i++){
        int tx1,ty1;
        tx1=x1+dx[i];ty1=y1+dy[i];
        if(tx1<1||tx1>8) continue ;
        if(ty1<1||ty1>8) continue ;
        if(vis1[tx1][ty1]) continue;
        vis1[tx1][ty1]=1;
        for(int j=0;j<4;j++){
            int tx2,ty2;
            tx2=x2+dx[j];ty2=y2+dy[j];
            if(tx2<1||tx2>8) continue ;
            if(ty2<1||ty2>8) continue ;
            if(vis2[tx2][ty2]) continue;
            vis2[tx2][ty2]=1;
            dfs(tx1,ty1,tx2,ty2);
            vis2[tx2][ty2]=0;
        }
        vis1[tx1][ty1]=0;
    }
}
int main(){
    int t;
    cin>>t;
    int x[5],y[5];
    while(t--){
        int cnt=1;
        char ts[25];
        for(int i=1;i<=8;i++){
            scanf("%s",ts);
            for(int j=1;j<=8;j++){
                m[i][j]=ts[j-1];
                if(m[i][j]=='K'){
                    x[cnt]=i;y[cnt]=j;cnt++;
                    m[i][j]='.';
                }
            }
        }
        flag=0;
        dfs(x[1],y[1],x[2],y[2]);
        A:;
        if(flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}
/*
2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K.......
*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值