杭电acm1264

//据说使用线段树的 
#include <stdio.h>
#include <string.h>
#define N 101

int i, j, ans, buf[N][N];

void print() {
	ans = 0;
	for(i=0; i<N; i++)
		for(j=0; j<N; j++)
			if(buf[i][j])
				ans ++;
	printf("%d\n", ans);
}

int main() {
	
	int ax, ay, bx, by, tmp;
	
	//memset(buf, 0, sizeof(buf));
	while(~scanf("%d%d%d%d", &ax, &ay, &bx, &by)) {
		if(ax==-1 && bx==-1 && ay==-1 && by==-1) {
			print();
			memset(buf, 0, sizeof(buf));
			continue ;
		}
		if(ax==-2 && bx==-2 && ay==-2 && by==-2) {
			print();
			break ;
		}
		if(ax>bx) {
			tmp = ax;
			ax = bx;
			bx = tmp;
		}
		if(ay>by) {
			tmp = ay;
			ay = by;
			by = tmp;
		}
		for(i=ax; i<bx; i++) {
			for(j=ay; j<by; j++) {
				buf[i][j] = 1;
			}
		}
			
	}
	
	return 0;
}

posted @ 2015-12-20 14:52  StevenLuke  阅读(94)  评论(0编辑  收藏  举报