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:为什么re了! 题用排序吗?还是我这样模拟错了!In Reply To:为什么re了! 题用排序吗?还是我这样模拟错了! Posted by:wangbaobao at 2009-05-02 20:29:32 #include"iostream" #define Max 5999 using namespace std; int stone_list[Max][Max]; int main() { int n; cin>>n; while(n--) { memset(stone_list,-1,sizeof(stone_list)); int hang,lie,stone_num,num=0; cin>>hang>>lie>>stone_num; while(stone_num--) { int x,y; cin>>x>>y; stone_list[x][y]=1; } for(int i=1;i<=hang;i++) for(int j=1;j<=lie;j++) { if(stone_list[i][j]==1) continue; else { stone_list[i][j]=1; if(i-1>=1&&stone_list[i-1][j]!=1) { stone_list[i-1][j]=1; num++; } else if(i+1<=hang&&stone_list[i+1][j]!=1) { stone_list[i+1][j]=1; num++; } else if(j-1>0&&stone_list[i][j-1]!=1) { stone_list[i][j-1]=1; num++; } else if(j+1<=lie&&stone_list[i][j+1]!=1) { stone_list[i][j+1]=1; num++; } } } cout<<num<<endl; } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator