当前位置:网站首页>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;
}
边栏推荐
- Neo4j: 1. CQL statement
- 【FPGA教程案例47】图像案例7——基于FPGA的RGB图像转化为灰度图实现,通过MATLAB进行辅助验证
- R文件找不到问题
- 牛客2022 暑期多校6 B Eezie and Pie(树上差分 + 倍增求第 kth 祖先板子)
- 开源一夏 | RuntimeException 子类
- Digital currency perpetual contract exchange development and development functions and code presentation
- Detailed explanation of JVM memory model and structure (five model diagrams)
- 记录贴:pytorch学习Part2
- what‘s the meaning of xenial
- 记录贴:pytorch学习Part4
猜你喜欢
随机推荐
建设必要的是什么意思
CS231n: 11 Generative Models
智文最终版本
canvas城市灯火夜景动画js特效
同态加密:正则嵌入、理想格和RLWE问题
C语言每日一练——Day01:求最大公约数(三种方法)
CF533B(树形dp+转移技巧)
Tensorflow教程(五)——MNIST项目提高
CF1716D(“按顺序“的完全背包)
MySQL中怎么对varchar类型排序问题
what‘s the meaning of build-essential
企业“数字化转型”成功的2个必备条件!
21天学习第四天--流程控制
How to set timed network disconnection to assist self-discipline in win10
一甲子,正青春,CCF创建六十周年庆典在苏州举行
List<String>用空串替换null值,并且都加上单引号,并且转为字符串用,分割
史上最强IDEA工具使用教程,你想要的全都有!
Cyanine5 tetrazine,Cy5 tetrazineCY5四嗪,1427705-31-4
Tess4J OCR简单使用教程
C人脸识别









