随笔分类 -  代码 科技

摘要:测时间 可以用 chrono 库中的获取时间函数,在程序内首尾相减即可。 For Linux: time ./a。real 一栏的即运行时间。 测空间 可以在文件首尾定义两个 char,相减即可,但是这个方法只能测量静态内存。 For Windows: 文件资源管理器。 For Linux: sys 阅读全文
posted @ 2026-02-04 21:50 dengchengyu 阅读(5) 评论(0) 推荐(0)
摘要:一类树哈希方法 记 \(s(x)\) 表示子树 \(x\) 的哈希值(对 \(2^{64}\) 取模),则: \[s(x)=1+\sum _{v\in son_x} f(s(v)) \]其中 \(f\) 是整数到整数的映射,可以使用 Xor Shift,可以在前后 Xor Shift 异或一个固定的 阅读全文
posted @ 2025-11-07 07:19 dengchengyu 阅读(14) 评论(0) 推荐(0)
摘要:手写哈希表 & 既好写又快的 pbds 哈希表 例题:P11615 【模板】哈希表 - 洛谷。 手写哈希表 const int M=1e7+19; struct _hash { ull key[M],val[M],mix; _hash() { mix=mt19937_64(chrono::stead 阅读全文
posted @ 2025-08-14 22:40 dengchengyu 阅读(134) 评论(0) 推荐(1)
摘要:NOI Linux 2.0 竞赛环境食用指北 终端 使用 Ctrl+Alt+T 在当前登录用户的目录 ~ 中打开终端,也可以在文件夹中 右键 或 Shift+右键 在当前文件夹打开终端。 运行可执行文件需要加 ./,例如 ./<filename>。注意 Linux 中可执行文件是没有后缀名的。 mk 阅读全文
posted @ 2025-01-04 19:17 dengchengyu 阅读(250) 评论(0) 推荐(0)
摘要:使用 <chrono> 测量程序用时 & 生成随机种子 用 <chrono> 测量程序执行时间 头文件 <chrono>,命名空间 std::chrono。 chrono 中提供了三种获取当前时钟的命名空间的成员函数: chrono::system_clock::now(),系统时间,可能回退,可用 阅读全文
posted @ 2024-11-26 15:15 dengchengyu 阅读(422) 评论(0) 推荐(1)
摘要:各种内置函数技巧总结 数学库等 abs(x) 取绝对值,自动类型,注意没有 abs(__int128)。 (int)(x*100+0.5)/100.0 四舍五入保留两位小数。 printf("%.2lf",x) 以 double 类型输出 \(x\) 保留两位小数,有时不一定四舍五入。long do 阅读全文
posted @ 2024-11-16 16:54 dengchengyu 阅读(62) 评论(0) 推荐(0)
摘要:__gnu_pbds::tree 用法简介 太长不看版 每次操作的复杂度是 \(O(\log n)\)。 #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> // or #include<bits/e 阅读全文
posted @ 2024-08-19 21:32 dengchengyu 阅读(547) 评论(0) 推荐(0)