Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
实在找不到错啊 我在自己电脑上试了好几次都可以通过的 求帮忙检查#include <iostream> #include <algorithm> #define maxn 1000 using namespace std; int solve(int n,int m,int a[maxn][maxn]){ if(n==1){ if(m==1) return a[n-1][m-1]; if(a[n-1][m-1]){ if(a[n-1][m-2]) return solve(n,m-1,a); else return solve(n,m-1,a)+1; } else return solve(n,m-1,a); } else{ int add=0; for(int j=0;j<m;j++){ if(a[n-1][j]){ if(j>0&&a[n-2][j-1]||a[n-2][j]||j<m-1&&a[n-2][j+1]||j>0&&a[n-1][j-1]) continue; else add++; } } return solve(n-1,m,a)+add; } } int main(){ int n,m; cin>>n>>m; int a[maxn][maxn]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ char t; cin>>t; if(t=='W'||t=='w') a[i][j]=1; else a[i][j]=0; } } cout<<solve(n,m,a); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator