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 |
WA通过不了啊 求解#include <iostream> #include <stdio.h> #include <algorithm> #include <stdlib.h> #include <string> #define N 50000 using namespace std; typedef struct node{ int x; int y; }Node; Node a[N]; bool cmp_x_y(Node a, Node b) { if(a.x==b.x) return a.y<b.y; else return a.x<b.x; } bool cmp_y_x(Node a, Node b) { if(a.y==b.y) return a.x<b.y; else return a.y<b.y; } int main() { //freopen("C:\\acm.txt","r",stdin); int n=0; while(cin>>n && n!=0) { int sum=0; for(int i=0;i<n;i++) { cin>>a[i].x>>a[i].y; } sort(a,a+n,cmp_y_x);//y int x1=a[n-1].x, y1=a[n-1].y; sum++; sort(a,a+n,cmp_x_y);//x int x2=a[n-1].x, y2=a[n-1].y; if(x2>x1 || y2>y1) sum++; cout<<sum<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator