朱色虫居
Pages
Home
Featured Posts
2006/10/01
105-The Skyline Problem
/*
"The Skyline Problem"
Level:4.0
Date:2006/9/30
技巧:不允許output最後一個字元是空白,否則會P.E.
*/
#include
#define N 10000
int height[N+1]={0}; //記錄水平座標每一點的高.
int i=0,
l=0,r=0,h=0;
//FILE *fptr;
main(){
/* if((fptr=fopen("test.txt","r"))==NULL)
printf("File can't not be open!\n");
while(!feof(fptr)){
fscanf(fptr,"%d %d %d", &l,&h,&r);
*/
while(scanf("%d %d %d",&l,&h,&r) == 3){
for(i=l;i < r;i++){ if(height[i] < h) height[i]=h; } } h=0; int flag = 0; for(i=0;i < N;i++){ if(h != height[i+1]){ h=height[i+1]; if(!flag){ printf("%d ",i+1); flag = 1; } else printf(" %d ",i+1); printf("%d",h); } } printf("\n"); }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment