/* * @(#) msu95_c.c - Problem 'C' ("City projection") solution * of the ACM Programming Contest at the MSU in 1995. * (c) 1997 Ivan Maidanski http://ivmai.chat.ru * Freeware program source. All rights reserved. ** * Language: ANSI C * Tested with: Borland C++ v3.1 * Last modified: 1997-10-23 18:40:00 GMT+04:00 */ /* Input data file: c.dat */ #include int n; int l[100],h[100],r[100]; int height(int x) { int i,maxh=0; for (i=0;i=x && h[i]>maxh) maxh=h[i]; return maxh; } int main() { int x,lh,nh; FILE *f=fopen("c.dat","rt"); n=0; while (fscanf(f,"%*[^-0-9]%d%*[^0-9]%d%*[^-0-9]%d",&l[n],&h[n],&r[n])!=EOF) { if (l[n]>r[n]) { x=l[n]; l[n]=r[n]; r[n]=x; } n++; } fclose(f); for (x=-100,lh=0;x<=100;lh=nh,x++) if ((nh=height(x))!=lh) printf("%d %d ",x-(nh