摘要: 题目描述 解析 一道很有意思的题目和一份写得很优雅的C++代码。 问题关键在于如何高效求解曼哈顿距离 借用一位大神的图: 因此有公式:曼哈顿距离=\(max(|x_1'-x_2'|, |y_1'-y_2'|)\),其中\(x'=x+y, y'=y-x\).【切比雪夫距离】 为方便求解数组中的最大值和 阅读全文
posted @ 2024-04-03 23:26 yichen111 阅读(171) 评论(0) 推荐(0)
摘要: 前段时间配大作业环境改了很多配置,发现tasks.json和launch.json经常令自己很迷惑。网上找的配置有时会有各种各样的问题,在此记录一下上学期配好的配置文件,日后有时间再详细研究研究 tasks.json: { "version": "2.0.0", "tasks": [ { "type 阅读全文
posted @ 2024-04-03 14:27 yichen111 阅读(239) 评论(0) 推荐(0)
摘要: C++ auto start = chrono::system_clock::now(); /* do something */ auto end = chrono::system_clock::now(); chrono::duration<double> diff = end-start; co 阅读全文
posted @ 2024-04-03 13:07 yichen111 阅读(10) 评论(0) 推荐(0)
摘要: 方式1:使用stringstream拆分 #include<bits/stdc++.h> using namespace std; string nums; int num; int main() { nums = "12 69 37 55a48"; stringstream ss(nums); w 阅读全文
posted @ 2024-04-03 13:01 yichen111 阅读(31) 评论(0) 推荐(0)