From 1f4768391dad772a868007b9763ab0b66011aef0 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Thu, 2 Oct 2025 19:49:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0P8435.cpp=E5=92=8CP45?= =?UTF-8?q?54.cpp=E8=A7=A3=E9=A2=98=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P4554.cpp实现了一个基于双端队列的BFS算法,用于解决网格图中的最短路径问题 --- src/10/2/P4554.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++ src/10/2/P8435.cpp | 9 +++++++ 2 files changed, 71 insertions(+) create mode 100644 src/10/2/P4554.cpp create mode 100644 src/10/2/P8435.cpp diff --git a/src/10/2/P4554.cpp b/src/10/2/P4554.cpp new file mode 100644 index 0000000..571079d --- /dev/null +++ b/src/10/2/P4554.cpp @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +using ll = int64_t; +#define sl static inline +const ll maxn = 505; +ll n,m,x1,y1,x2,y2,inf=1e9+7; +char c[maxn][maxn]; +ll ans[maxn][maxn]; + +struct P{ + ll x,y,s; +}; + +ll dis[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; + +sl int solve(){ + std::cin>>n>>m; + if(n==0 && m==0)return 1; + for(ll i=0;i>c[i][j]; + ans[i][j]=inf; + } + } + // printf("line = %d\n",__LINE__); + std::cin>>x1>>y1>>x2>>y2; + std::deque

dq; + dq.emplace_back(x1,y1,0); + while(dq.size()){ + auto [x,y,s] = dq.front(); + dq.pop_front(); + for(ll i=0;i<4;i++){ + ll nx=x+dis[i][0],ny=y+dis[i][1]; + if(nx<0||nx>n-1||ny<0||ny>m-1)continue; + ll ns = s+(c[x][y]!=c[nx][ny]); + if(nx==x2&&ny==y2){ + std::cout< + +using ll = int64_t; + + + +int main(){ + +} \ No newline at end of file