| ||||||||||
| 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 | |||||||||
Re:用别人的测试数据都正确,为何仍然WA?代码如下,请高人指点In Reply To:用别人的测试数据都正确,为何仍然WA?代码如下,请高人指点 Posted by:Hammer307 at 2009-04-16 18:59:40 > #include <iostream>
> using namespace std;
> int a[101][101],r,c,i,j,k;
> int f(int x,int y)
> {
> if(x<1||x>r||y<1||y>c||a[x][y]==0)
> return 0;
> a[x][y]=0;
> return 1+f(x-1,y)+f(x+1,y)+f(x,y-1)+f(x,y+1);
> }
> int main()
> {
> cin>>r>>c>>k;
> while(k--){
> //scanf("%d%d",&i,&j);
> cin>>i>>j;
> a[i][j]=1;
> }
> int max=-1,s;
> for(i=1;i<=r;i++)
> for(j=1;j<=c;j++){
> if(a[i][j])
> s=f(i,j);
> if(max<s)
> max=s;
> }
> cout<<max<<endl;
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator