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 |
我了个去,数组大小看到100000无限WA,无奈开到1000000就AC,要求只有50000啊?!#include <stdio.h> #define MAX 1000000 typedef struct { int x; int y; } point; point pt[MAX]; int f[MAX],g[MAX]; int main() { int cases,m,n,i,j,max; scanf("%d",&cases); for(i=0,max=0; i<cases; i++) { scanf("%d%d",&pt[i].x,&pt[i].y); if(max<pt[i].y) max=pt[i].y; } for(i=0; i<cases; i++) { m=pt[i].x; n=pt[i].y; if(m==n) g[m]=1; else { for(j=m; j<n; j++) f[j]=1; } } for(i=1; i<=max; i++) { if(f[i]==1) { printf("%d ",i); while(f[++i]==1); printf("%d\n",i); } else if(g[i]==1) printf("%d %d\n",i,i); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator