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了!这题用排序吗?还是我这样模拟有问题 #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