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

where is my fault?

Posted by xiaxia123 at 2006-08-10 19:34:23 on Problem 2953
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;

typedef struct
{
	short x;
	short y;
}RE;

int m,n;
int PA[21][21], PB[21][21];
int N;
RE res[400];

bool cmp(const RE & a, const RE & b)
{
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}

void Go()
{
	int i,j,k,f;
	for ( i=1; i<=m; i++)
	{
		for ( j=1; j<=n; j++)
		{
			f = 1;
			for ( k=1; k<=n; k++)
			{
				if (PB[i][k] > PB[i][j])
				{ 
					f = 0;
					break;
				}
			}
			if (f) 
			{
				for ( k=1; k<=n; k++)
				{
					if (PA[k][j] > PA[i][j])
					{
						f = 0;
						break;
					}
				}
			}
			if (f) 
			{
				res[N].x = i;
				res[N++].y = j;
			}
		}
	}
}
					


int main()
{
	int i, j;
	while (cin>>m>>n && m && n)
	{
		for ( i=1; i<=m; i++)
			for ( j=1; j<=n; j++)
				cin>>PA[i][j];
		for ( i=1; i<=m; i++)
			for ( j=1; j<=n; j++)
				cin>>PB[i][j];

		N = 0;
		memset(res, 0, sizeof(res));
		
		Go();
		sort(res, res+N, cmp);
		cout<<N<<endl;
		for ( i=0; i<N; i++)
			cout<<res[i].x<<" "<<res[i].y<<endl;
	}
	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