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 |
我为什么会RE?#include <stdio.h> long d[10001][2]; long n; void swap(long &a,long &b) { long temp=a; a=b; b=temp; } void qsort(long h,long t) { if (h>=t) return ; int i=h,j=t,mid=d[(h+t)/2][1]; do { while (d[i][1]>mid) i++; while (d[j][1]<mid) j--; if (i<=j) {swap(d[i][1],d[j][1]); swap(d[i][0],d[j][0]); i++;j--;} }while (i<=j); qsort(h,j);qsort(i,t); } int main() { long n; while (1) { scanf("%ld",&n); if (n==0) break; long i; for (i=1;i<=n;i++) scanf("%ld %ld",&d[i][0],&d[i][1]); d[0][0]=0; d[0][1]=0; qsort(1,n); long j=1,maxx=0; while (d[j][1]==d[1][1]) {if (maxx<d[j][0]) maxx=d[j][0]; j++;} long max=maxx,re=1; for (i=j;i<=n;i++) { maxx=0; j=i; while (d[j][1]==d[i][1] && j<=n) {if (maxx<d[j][0]) maxx=d[j][0]; j++;} if (maxx>max) { max=maxx; re++; } i=j; } printf("%ld\n",re); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator