码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces 15B Laser

时间:2014-06-29 23:48:09      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:blog   http   get   2014   os   name   

题目链接:点击打开链接


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<queue>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 5005
#define ll __int64
inline ll Abs(ll x){return x>0?x:-x;}
int main(){
	ll i, j, T;cin>>T;
	while(T--){
		ll x1,y1,x2,y2,n,m;
		scanf("%I64d %I64d %I64d %I64d %I64d %I64d",&n,&m,&x1,&y1,&x2,&y2);
		ll minn = min(x1,x2), maxx = max(x1,x2);
		x1 = minn, x2 = maxx;
		x2 -= x1-1;
		x1 = 1;
		minn = min(y1,y2), maxx = max(y1,y2);
		y1 = minn, y2 = maxx;
		y2 -= y1-1;
		y1 = 1;
		if(x1==x2 || y1==y2) {
			if(y1==y2) {
				swap(n,m); swap(x1,y1); swap(x2,y2);
			}
			ll cha1 = y2-y1-1, cha2 = m - y2;
			cha1 -= cha2;
			cha1 = max(cha1, 0ll);
			printf("%I64d\n",n*cha1);
		}
		else {
			ll x3 = x1+(n-x2), y3 = y1+(m-y2);;
			if(x3>=(x2-1) && y3>=(y2-1))
			printf("%I64d\n", (x2-x1)*(y2-y1)*2);
			else 
				printf("%I64d\n",n*m-(x3-x1+1)*(y3-y1+1)*2);
		}
	}
	return 0;
}


Codeforces 15B Laser,布布扣,bubuko.com

Codeforces 15B Laser

标签:blog   http   get   2014   os   name   

原文地址:http://blog.csdn.net/qq574857122/article/details/35636413

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!