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

求助大牛以下错在哪

Posted by jlnu123 at 2009-06-21 18:11:59 on Problem 3314
#include <iostream>
#include <memory>
using namespace std;
bool ins1[100][10];
bool ins2[100][10];
bool temp[100][10];
int main()
{
	int i,j,k,res,num,width,height,row1,row2,tmp,t;
	char ch;
	while(cin>>num>>width>>height)
	{
		if(!(num+width+height))
			break;
		for(k=0;k<num;++k)
		{	
			if(!k)
			{
				cin>>row1;
			    for(i=0;i<row1;++i)
			   	   for(j=0;j<width;++j)
				   {
				    	cin>>ch;
					    if(ch=='X')
						    ins1[i][j]=1;
				     	else
						    ins1[i][j]=0;
				   }
				res=row1;
			}
			else
			{
				cin>>row2;
			    for(i=0;i<row2;++i)
			   	    for(j=0;j<width;++j)
					{
				        cin>>ch;
					    if(ch=='X')
						    ins2[i][j]=1;
				        else
						    ins2[i][j]=0;
					}
				bool flag=true;
				tmp=0;
				for(i=row2-1;i>=0;--i)
				{
					if(flag)
					{
					    ++tmp;
				     	if(tmp<=row1)
						{
					    	for(t=0;t<tmp && flag;++t)
					            for(j=0;j<width && flag;++j)
							       if(!((ins1[tmp-1-t][j] && !ins2[row2-1-t][j]) || !ins1[tmp-1-t][j]))
								       flag=false;       
						}
					}
				}
			
			
				if(res+row2+1-tmp>=height)
				{
					cout<<res<<" ";
					res=0;
					if(k==num-1)
					
						cout<<row2<<endl;

				}
				else
				{
					res += (row2 + 1 - tmp);
					if(k==num-1)
					{
						cout<<res<<endl;
						res=0;
					}
					for(t=0;t<row2+1-tmp;++t)
						for(j=0;j<width;++j)
							temp[t][j]=ins2[t][j];
					for(i=0;i<tmp;++i)
					{
						for(j=0;j<width;++j)
							temp[t][j]=ins1[i][j]|ins2[t][j];
						++t;
					}
					for(i=tmp;i<row1;++i)
					{
						for(j=0;j<width;++j)
							temp[t][j]=ins1[i][j];
						++t;
					}
					row1=res;

					for(i=0;i<row1;++i)
						for(j=0;j<width;++j)
							ins1[i][j]=temp[i][j];

				}
			}
		}
	}

	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