70求救!!!
  • 板块P1605 迷宫
  • 楼主emo114514
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/1/26 20:04
  • 上次更新2025/1/27 08:49:58
查看原帖
70求救!!!
1421094
emo114514楼主2025/1/26 20:04
#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int n,m,t,ans;
pair<int,int> x,y,a;
int d[4][2]= {{-1,0},{0,-1},{0,1},{1,0}};
int kkk[6][6];
bool cff_0102[6][6];
void dfs(int w,int z)
{
    if (w==y.f&&z==y.s)
    {
        ans++;
        return;
    }
    else
    for (int i=0; i<4; i++)
    {
        int ccf=w+d[i][0],cff=z+d[i][1];
        if (kkk[ccf][cff]==0&&(!cff_0102[ccf][cff]))
        {
            cff_0102[ccf][cff]=true;
            dfs(ccf,cff);
            cff_0102[ccf][cff]=false;
        }
    }
}
int main()
{
    cin>>n>>m>>t>>x.f>>x.s>>y.f>>y.s;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            kkk[i][j]=0;
    for (int i=0; i<t; i++)
    {
        cin>>a.f>>a.s;
        kkk[a.f][a.s]=1;
    }
    dfs(x.f,x.s);
    cout<<ans;
    return 0;
}

求大佬指教!!!

2025/1/26 20:04
加载中...