SkyWT

SkyWT

我们的征途是星辰大海

🚧 博客系统即将搬迁,将集成到 skywt.cn/blog。欢迎体验!
📧 现在可以使用邮箱订阅本博客。欢迎订阅!

引言

Bitset 是一种利用对布尔数组压位存储的方法,达到优化时间常数、空间常数的目的的黑科技。利用 Bitset,可以方便地对布尔数组进行按位逻辑运算,优化 32 或 64 的常数。在某些素质极差的卡常题中运用会有奇效。

More...


Problem Description

YJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination.
One day, he is going to travel from city $A$ to southeastern city $B$. Let us assume that A is $(0,0)$ on the rectangle map and $B (10^9,10^9)$. YJJ is so busy so he never turn back or go twice the same way, he will only move to east, south or southeast, which means, if YJJ is at $(x,y)$ now $(0\leqslant x\leqslant 10^9,0\leqslant y\leqslant 10^9)$, he will only forward to $(x+1,y)$, $(x,y+1)$ or $(x+1,y+1)$.

More...


今天考试的时候遇到一题背包题目,我直接打了暴力的 0/1 背包,理论复杂度是 $\Theta (N^3\ast W)$,大概是 $10^9$ 这个级别……时限 1s,交上去就全部 TLE 了……然后我就想起了这个终极优化模板,加上以后居然全 A 了!时间居然只有 200ms 左右……

$10^9$ 级别居然都可以压过去!!!

More...


在c++中,vector 是一个十分有用的容器。它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。
vector 在C++ 标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。

More...


C++里有普通的 32 位整数类型 int 和 64 位整数类型 long long,但是如果我们要存一个128位的整数,前两个似乎就无能为力了。这时候我们就要用到 __int128这种类型了。

More...


洛谷链接:P1577 切绳子

看到我写这么简单的题的题解不要奇怪,因为这题很坑……XJ一大堆dalao都已经被坑害了……

More...


在C语言中,我们使用宏定义函数这种借助编译器的优化技术来减少程序的执行时间,那么在C++中有没有相同的技术或者更好的实现方法呢?答案是有的,那就是内联函数。内联函数作为编译器优化手段的一种技术,在降低运行时间上非常有用。我们将从:

  • 什么是内联函数
  • 为什么要使用内联函数
  • 内联函数优缺点分析
  • 何时使用内联函数

这四个方面对内联函数进行介绍。

More...


POJ题目链接

N soldiers of the land Gridland are randomly scattered around the country.
A position in Gridland is given by a pair (x,y) of integer coordinates. Soldiers can move - in one move, one soldier can go one unit up, down, left or right (hence, he can change either his x or his y coordinate by 1 or -1).

More...