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 |
帮忙看一下了 Thanks!!!!!!#include <iostream> using namespace std; int main() { int n,max=0,a[100][100]; char t; scanf("%d",&n); for(int i=0;i<n;i++) for(int j=0;j<n;j++) { scanf("%c",&t); if(t=='*')a[i][j]=0; else if(t=='J')a[i][j]=1; else if(t=='B')a[i][j]=2; else j--; } for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(a[i][j]==1) { for(int k=n-1;k>max;k--) { if(i-k>=0&&j-k>=0)if(a[i-k][j]*a[i-k][j-k]*a[i][j-k]==1)max=k*k; else if(i-k>=0&&j+k<n)if(a[i-k][j]*a[i-k][j+k]*a[i][j+k]==1)max=k*k; else if(i+k<n&&j-k>=0)if(a[i+k][j]*a[i+k][j-k]*a[i][j-k]==1)max=k*k; else if(i+k<n&&j+k<n)if(a[i+k][j]*a[i+k][j+k]*a[i][j+k]==1)max=k*k; } for(int k=n/2;2*k*k>max;k--) { if(i-2*k>=0&&j-k>=0&&j+k<n)if(a[i-2*k][j]*a[i-k][j-k]*a[i-k][j+k]==1)max=2*k*k; else if(i+2*k<n&&j-k>=0&&j+k<n)if(a[i+2*k][j]*a[i+k][j-k]*a[i+k][j+k]==1)max=2*k*k; else if(i-k>=0&&i+k<n&&j-2*k>=0)if(a[i+k][j-k]*a[i-k][j-k]*a[i][j-2*k]==1)max=2*k*k; else if(i-k>=0&&i+k<n&&j+2*k<n)if(a[i-k][j+k]*a[i+k][j+k]*a[i][j+2*k]==1)max=2*k*k; } } for(int i=0;i<n;i++) for(int j=0;j<n;j++) { if(a[i][j])continue; for(int k=n-1;k>max;k--) { if(i-k>=0&&j-k>=0)if(a[i-k][j]*a[i-k][j-k]*a[i][j-k]==1)max=k*k; else if(i-k>=0&&j+k<n)if(a[i-k][j]*a[i-k][j+k]*a[i][j+k]==1)max=k*k; else if(i+k<n&&j-k>=0)if(a[i+k][j]*a[i+k][j-k]*a[i][j-k]==1)max=k*k; else if(i+k<n&&j+k<n)if(a[i+k][j]*a[i+k][j+k]*a[i][j+k]==1)max=k*k; } for(int k=n/2;2*k*k>max;k--) { if(i-2*k>=0&&j-k>=0&&j+k<n)if(a[i-2*k][j]*a[i-k][j-k]*a[i-k][j+k]==1)max=2*k*k; else if(i+2*k<n&&j-k>=0&&j+k<n)if(a[i+2*k][j]*a[i+k][j-k]*a[i+k][j+k]==1)max=2*k*k; else if(i-k>=0&&i+k<n&&j-2*k>=0)if(a[i+k][j-k]*a[i-k][j-k]*a[i][j-2*k]==1)max=2*k*k; else if(i-k>=0&&i+k<n&&j+2*k<n)if(a[i-k][j+k]*a[i+k][j+k]*a[i][j+2*k]==1)max=2*k*k; } } printf("%u\n",max); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator