当前位置:网站首页>uva1468
uva1468
2022-08-08 17:50:00 【小刀刺大熊】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 6e4 + 7;
int m, n,h[maxn];
pair<int, int> a, b;
int main()
{
int t,x,y;
cin >> t;
while (t--) {
memset(h, 0x3f3f3f3f, sizeof(h));
cin >> m >> n;
cin >> a.first >> a.second;
cin >> b.first >> b.second;
for (int i = 3; i <= n; i++) {
cin >> x >> y;
if (x < a.first || x > b.first) continue;
h[x] = min(h[x],abs(y - a.second) - 1);
}
h[a.first] = -1;
for (int i = a.first + 1; i < b.first; i++) h[i] = min(h[i - 1] + 1, h[i]);
h[b.first] = -1;
for (int i = b.first - 1; i > a.first; i--) h[i] = min(h[i + 1] + 1, h[i]);
long long int ans = 0;
for (int i = a.first + 1; i < b.first; i++) {
if (h[i] == -1) continue;
int high = min(a.second + h[i], m - 1);
int low = max(a.second - h[i], 0);
ans += high - low + 1;
}
cout << ans << endl;
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
【20210923】Choose the research direction you are interested in?
医疗机构漏诊,该不该赔?--一起交通事故多处骨折,又遇到医疗机构漏诊
Qt——选择文件夹并获取路径以及文件夹下子文件
建设必要的是什么意思
Tess4J OCR简单使用教程
Node基于TCP建立的服务器
【目标检测】YOLOv5:标签中文显示/自定义颜色
2.MySQL链接和创建数据库,创建数据表
Edu Codeforces 103 (div2)
牛客2022 暑期多校6 B Eezie and Pie(树上差分 + 倍增求第 kth 祖先板子)
MySQL中怎么对varchar类型排序问题
【目标检测】小脚本:根据xml批量复制jpg图片
LeetCode(剑指 Offer)- 21. 调整数组顺序使奇数位于偶数前面
Reprinted, the fragment speaks very well, the big guy
C语言每日一练——Day01:求最大公约数(三种方法)
spark学习笔记(八)——sparkSQL概述-定义/特点/DataFrame/DataSet
【教程2】疯壳·ARM功能手机-测试程序介绍
Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素用于缩短包封周期
@Transactional
CF696C(计数推公式+欧拉降幂)