Codeforces 15B Laser

题目链接:点击打开链接

#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;
}
上一篇:OpenGL笔试题


下一篇:sjtu1333 函数时代