#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>PII;
const int N=1e7+5;
int n,m;
int e[N],h[N],w[N],ne[N],idx;
int dist[N];
bool st[N];
void add(int a,int b,int c){
e[idx]=b,w[idx]=c,ne[idx]=h[a],h[a]=idx++;
}
inline int wz(int i,int j){
return i*(m+1)+j+1;
}
int jstradi(){
priority_queue<PII,vector<PII>,greater<PII> >heap;
memset(dist,0x3f,sizeof dist);
dist[1]=0;
heap.push({0,1});
while(heap.size()) {
PII t=heap.top();
int d=t.first,v=t.second;
heap.pop();
st[v]=1;
if(v==n)break;
for(int i=h[v];~i;i=ne[i]) {
int j=e[i];
if(!st[j]&&dist[j]>dist[v]+w[j]){
dist[j]=d+w[i];
heap.push({dist[j],j});
}
}
}
}
int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
memset(h,-1,sizeof h);
cin>>n>>m;
if((n+m)%2!=0){
cout<<"NO SOLUTION";
return 0;
}
int a,b,c;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
char c;
cin>>c;
if(i==0&&j==0&&c=='/'){
cout<<"NO SOLUTION";
return 0;
}
a=wz(i,j);
b=wz(i+1,j+1);
if(c=='\\'){
if((i+j)%2)add(a,b,0),add(b,a,0);
else add(a,b,1),add(b,a,1);
}else{
if((i+j)%2==0)add(b,a,0),add(a,b,0);
else add(a,b,1),add(b,a,1);
}
}
}
cout<<dist[n];
return 0;
}
请问有大佬可以看看吗,谢谢