Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮忙看一下了 Thanks!!!!!!

Posted by testinf at 2007-07-14 20:42:21 on Problem 3251
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator