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

为什么Wrong Answer,Help!Help!Help!

Posted by stream_speed at 2006-08-03 17:16:07 on Problem 2920
#include <iostream>
using namespace std;
const int w1[9]={0,-1,-1,0,1,1,1,0,-1};
const int w2[9]={0,0,1,1,1,0,-1,-1,-1};
int a[310][310],c[100000][2];
int n,m,op,cl;
void work()
{ int i,j,k,x,y;
  memset(a,0,sizeof(a));
  memset(c,0,sizeof(c));
  cin >>n >>m;
  for (i=1; i<=m; i++)
  { cin >>j >>k;
    a[j][k]=-1;
  }
  for (i=1; i<=n; i++)
  for (j=1; j<=n; j++)
  if (a[i][j]==-1)
  { for (k=1; k<=8; k++)
    { x=i+w1[k];
      y=j+w2[k];
      if (a[x][y]==0) a[x][y]=1;
    }
  }
  x=n/2+1;
  y=n/2+1;
  if (a[x][y]==1) a[x][y]=2;
  if (a[x][y]==0)
  { cl=1;
    op=0;
    c[1][0]=x;
    c[1][1]=y;
    while (op<cl)
    { op++;
      j=c[op][0];
      k=c[op][1];
      if (a[j][k]==0)
      { a[j][k]=-2;
        for (i=1; i<=8; i++)
        { x=j+w1[i];
          y=k+w2[i];
          if (x==0) continue;
          if (x==n+1) continue;
          if (y==0) continue;
          if (y==n+1) continue;
          if (a[x][y]>0) a[x][y]=2;
          if (a[x][y]==0)
          { cl++;
            c[cl][0]=x;
            c[cl][1]=y;
          }
        }
      }
    }
  }
  for (i=1; i<=n; i++)
  { for (j=1; j<=n; j++)
    { if (a[i][j]==0) cout <<"?";
      if (a[i][j]==1) cout <<"?";
      if (a[i][j]==2) cout <<"#";
      if (a[i][j]==-1) cout <<"*";
      if (a[i][j]==-2) cout <<".";
    }
    cout <<endl;
  }
}
int main()
{ int i,j,k;
  cin >>k;
  for (i=1; i<=k; i++)
  { if (i!=1) cout <<endl;
    cout <<"Scenario #" <<i <<":" <<endl;
    work();
  }
  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