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

无语的WA,谁帮着找找错啊!!!

Posted by 771385494 at 2011-11-07 21:27:32 on Problem 3636
#include <iostream>
#include <cstdlib>
using namespace std;
struct doll_size{
	int w,h;
};
int compare(const void *arg1,const void *arg2)
{
	return (* (int *)arg1 < * (int *)arg2) ? -1 : (* (int *)arg1 > * (int *)arg2) ? 1 : 0;
}
int main()
{
	int nCases,n,i,j;
	struct doll_size array[20000];
	cin >> nCases;
	while(nCases--){
		cin >> n;
		for(i = 0;i < n;i++)
			cin >> array[i].w >> array[i].h;
		qsort(array,n,sizeof(int) * 2,compare);
		int count = 1;
		for(i = 1;i < n;i++){
			if(array[i].w > array[i - 1].w){
				if(array[i].h <= array[i - 1].h)
					count++;
			}
			else{
				count++;
			}	
		}
		cout << count << 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