cgxd @ 2024-04-17 21:27:25
提交后发现上面写着编译错误,可在devc++上运行的好好的啊
#include<bits/stdc++.h>
using namespace std;
int n, x1, y1, x2, y2;
vector<bitset<1005>> bs;
int vis[1005][1005];
complex<int> c1, c2;
complex<int> c[] = {complex<int>(1, 0), complex<int>(0, 1), complex<int>(-1, 0), complex<int>(0, -1)};
queue<complex<int>> q;
int main(){
cin >> n;
for(int i = 0; i < n; i++){
string s;
cin >> s;
reverse(s.begin(), s.end());
bitset<1005> bs1(s);
bs.push_back(bs1);
}cin >> x1 >> y1 >> x2 >> y2;
x1--, y1--, x2--, y2--;
c1 = complex<int>(x1, y1);
c2 = complex<int>(x2, y2);
q.push(c1);
while(q.size()){
complex<int> comp(q.front());
int x = comp.real(), y = comp.imag();
int k = vis[x][y] + 1;
q.pop();
for(complex<int> c3: c){
complex<int> c4(comp + c3);
int x1 = c4.real(), y1 = c4.imag();
if(x1 < 0 or x1 > n or y1 < 0 or y1 > n or bs[x1][y1])
continue;
vis[x1][y1] = k;
q.push(c4);
if(q.back() == c2){
cout << k;
return 0;
}
}
}
}
by yx666 @ 2024-04-17 21:33:28
y1
是 std 中的一个函数,重名了,换一个名字应该就行了。
by cgxd @ 2024-04-22 22:52:34
@yx666 啊?才知道还有这么奇怪的函数名字