蒟蒻求助,50分
  • 板块P1605 迷宫
  • 楼主yzkadbq_qwq
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/1/23 11:34
  • 上次更新2023/10/28 11:28:30
查看原帖
蒟蒻求助,50分
573334
yzkadbq_qwq楼主2022/1/23 11:34
#include<bits/stdc++.h>
using namespace std;
bool a[7][7]={0},vis[7][7];
int n,m,t,sx,sy,fx,fy;
long long cnt=0;
short dx[4]={0,0,1,-1};
short dy[4]={1,-1,0,0};
void dfs(int x,int y){
    if(x>n or x<1 or y>m or y<1 or a[x][y]==1 or vis[x][y]==1){
        return;
    }
    if(x==fx and y==fy){
        cnt++;
        return;
    }
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        vis[x][y]=1;
        dfs(nx,ny);
        vis[x][y]=0;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m>>t;
    cin>>sx>>sy>>fx>>fy;
    for(int i=1;i<=t;i++){
        int b,c;
        cin>>b>>c;
        a[b+1][c+1]=1;
    }
    dfs(sx,sy);
    cout<<cnt<<endl;
    return 0;
}
2022/1/23 11:34
加载中...