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

## 你写的太太太太烦了，即使是像你那样做也用不着这样的

Posted by frkstyc at 2005-10-20 14:13:51 on Problem 2659
In Reply To:贴出代码，为什么 wa? Posted by:00448312 at 2005-10-20 14:11:35
```> # include< iostream.h >
> struct Judge
> {
> 	int Rth_row;//第R行
> 	int Sth_column;//第S列
> 	int P;//正方形的边长，始终为奇数
> 	int T;//是否在爆炸的范围内
> };
>
> int position[101][101];
>
> void main()
> {
> 	int row_nums;
> 	int column_nums;
> 	int bomb_nums;
>
> 	int curr_begin_row,new_begin_row,false_begin_row;
> 	int curr_end_row,new_end_row,false_end_row;
> 	int curr_begin_column,new_begin_column,false_begin_column;
> 	int curr_end_column,new_end_column,false_end_column;
>
> 	int count;
> 	Judge judge[100];
>
> 	Judge true_judge[100];//保存判断为真的命题
> 	int true_count;
>
>
> 	Judge false_judge[100];//保存判断为假的判断
> 	int false_count;
>
> 	int i,j,t,k1,k2;
> 	int if_continue=1;
>
> 	cin>>row_nums>>column_nums>>bomb_nums;
>
>
> 		true_count=false_count=0;
> 		count=0;
>
> 		//(1) 将输入按照T==1? 分成两类
> 		for( i=0; i< bomb_nums; i++ )
> 		{
> 			cin>>judge[i].Rth_row>>judge[i].Sth_column>>judge[i].P>>judge[i].T;
> 			if( judge[i].T==1 )
> 				true_judge[true_count++]=judge[i];
> 			else
> 				false_judge[false_count++]=judge[i];
> 		}
>
> 		//(2) 先处理T=1的情况
>         // 生成所有T=1时，炸弹爆炸范围的交集(用四条边的边界记录，如下紧接下方的四个变量)
> 		curr_begin_row=curr_begin_column=-1;
> 		curr_end_row=curr_end_column=101;
>
> 		for( i=0; i< true_count; i++ )
> 		{
> 			//生成新炸弹的爆炸范围
> 			t= ( true_judge[i].P-1 )/2;
> 		    new_begin_row= ( true_judge[i].Rth_row - t >1 ? true_judge[i].Rth_row-t : 1 );
> 			new_end_row= ( true_judge[i].Rth_row + t > row_nums ? row_nums : true_judge[i].Rth_row + t );
> 			new_begin_column= ( true_judge[i].Sth_column - t >1? true_judge[i].Sth_column - t:1 );
> 			new_end_column= ( true_judge[i].Sth_column + t > column_nums? column_nums : true_judge[i].Sth_column + t );
>
> 			//生成交集，如果交集为空，则直接退出，否则生成新的交集
> 			if( new_begin_row > curr_end_row ||  new_end_row < curr_begin_row || new_begin_column > curr_end_column || new_end_column < curr_begin_column )
> 			{
>                 if_continue=0 ;
> 				break;
> 			}
> 			else
> 			{
> 				curr_begin_row= ( new_begin_row >= curr_begin_row ? new_begin_row : curr_begin_row );
> 				curr_end_row= ( new_end_row <= curr_end_row ? new_end_row: curr_end_row );
> 				curr_begin_column= ( new_begin_column >= curr_begin_column ? new_begin_column : curr_begin_column);
> 				curr_end_column=( new_end_column<=  curr_end_column ? new_end_column : curr_end_column );
> 			}
> 		}
>
> 		//(3)处理T=0的情况，将每一个 （T=0的bomb的范围）∩（前面求得的“可能范围”） 内的点变成0
> 		if( if_continue== 1 )
> 		{
>
> 			//将前面处理的可能存在范围内的的值变成1
> 			for( i= curr_begin_row; i<= curr_end_row; i++ )
> 				for( j= curr_begin_column; j<= curr_end_column; j++ )
> 					position[i][j]= 1;
>
> 			//求出可能存在范围
> 			for( i=0; i< false_count; i++ )
> 			{
> 				//生成爆炸范围
> 				t= ( false_judge[i].P-1 )/2;
> 				new_begin_row= ( false_judge[i].Rth_row - t >1 ? false_judge[i].Rth_row-t : 1 );
> 				new_end_row= ( false_judge[i].Rth_row + t > row_nums ? row_nums : false_judge[i].Rth_row + t );
> 				new_begin_column= ( false_judge[i].Sth_column - t >1? false_judge[i].Sth_column - t:1 );
> 				new_end_column= ( false_judge[i].Sth_column + t > column_nums? column_nums : false_judge[i].Sth_column + t );
>
> 				if( new_begin_row > curr_end_row ||  new_end_row < curr_begin_row || new_begin_column > curr_end_column || new_end_column < curr_begin_column )
> 					break;
> 				else
> 				{
> 					//生成错误范围和正确范围的交集
> 					false_begin_row= ( new_begin_row >= curr_begin_row ? new_begin_row : curr_begin_row );
> 					false_end_row= ( new_end_row <= curr_end_row ? new_end_row: curr_end_row );
> 					false_begin_column= ( new_begin_column >= curr_begin_column ? new_begin_column : curr_begin_column);
> 					false_end_column=( new_end_column<=  curr_end_column ? new_end_column : curr_end_column );
>
> 					//将错误的点剔除
> 					for( k1=false_begin_row; k1<= false_end_row; k1++ )
> 						for( k2= false_begin_column; k2<= false_end_column; k2++ )
> 							position[k1][k2]=0;
> 				}
> 			}
>
> 			// (4)统计剩余可能点
> 			for( i= curr_begin_row; i<= curr_end_row; i++ )
> 				for( j= curr_begin_column; j<= curr_end_column; j++ )
> 					if( position[i][j]== 1 )
> 						count++;
> 		}
>
>
>
>
> 	   cout<<count<<endl;
>
>
>
> }
>
>
>
>
>
>
>
>
>
>
>
```

Followed by:

User ID:
Title:

Content: