- 烦人的幻灯片(slides)
- 2019-10-03 10:34:39 @
代码:
#include<bits/stdc++.h>
#define ns "-1"
#define fs(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define ll long long
#define ull unsigned long long
#define ldb long double
#define m(a,b) memset(a,b,sizeof(a))
#define sz(a) sizeof(a)
using namespace std;
const int inf=2147483647;
const ldb pi=3.141592653589793238462643383279,ins=2147483647.0,eps=0.0000000001;
int n,a[1001][1001],s1,s2,e1,e2,ans=inf,p;
char num[1001];
/*
0上
1下
2←
3→
*/
void dfs(int x,int y,int step){
if(x==e1&&y==e2){
if(ans>step) ans=step;
return;
}
//cout<<"s:"<<step<<' '<<x<<' '<<y<<endl;
if(a[x][y]!=0) return;
if(x<1||x>n||y<1||y>n) return;
a[x][y]=2;
++step;
dfs(x+1,y,step);
dfs(x-1,y,step);
dfs(x,y-1,step);
dfs(x,y+1,step);
return;
}
int main(){
ios::sync_with_stdio(false);
cin>>n;
fs(i,1,n,1){
cin>>num;
p=strlen(num)-1;
fs(j,0,p,1){
a[i][j+1]=(int)(num[j]-'0');
}
}
cin>>s1>>s2>>e1>>e2;
dfs(s1,s2,0);
//fs(i,1,n,1) fs(j,1,n,1) cout<<a[i][j];
cout<<ans;
return 0;
}
2 条评论
-
房佳坤 LV 6 @ 2021-10-25 21:15:13
你这define写反了吧
#define fs(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define ll long long
应该先define long long啊
const ldb pi=3.141592653589793238462643383279,ins=2147483647.0,eps=0.0000000001;
long double 精度只有十几位 -
2020-07-09 10:56:27@
哇,还妹子呢,我看是女装大佬
- 1
信息
- 难度
- 8
- 分类
- (无)
- 标签
- 递交数
- 15
- 已通过
- 5
- 通过率
- 33%
- 被复制
- 2
- 上传者