algorithm_2024/README.md

47 lines
1.1 KiB
Markdown
Raw Normal View History

2024-10-12 11:29:37 +00:00
# algorithm_2024
algorithm_2024
## 错题本
### Luogu某题
#### 数组越界导致变量异常更改
### [OJ4980:拯救行动](http://noi.openjudge.cn/ch0205/4980/)
#### 未考虑无答案(特殊情况)时输出
#### 优先对联是从大到小排序重载运算符时需反向或者std::greater
```cpp
struct Status{
Point now;
ll step;
bool operator<(const Status &that)const noexcept{
return this->step > that.step;
}
};
std::priority_queue<Status> q;
2024-10-13 04:14:36 +00:00
```
### [P1330](https://www.luogu.com.cn/problem/P1330)
#### BFS时注意初始化一开始的去重数组
```cpp
void bfs(){
for(ll i{1};i<=n;i++){
color_sum[1]=color_sum[2]=0;
if(vis[i])continue;
q.push(i);
set_color(i, 1);
vis[i]=true; // 注意初始化错误
while(!q.empty()){
2024-10-13 05:36:20 +00:00
```
### [P3957](https://www.luogu.com.cn/problem/P3957)
#### 初始状态依赖已走过的部分时注意起始点状态
```cpp
for(ll coin{0};coin<=(points[n].posit-d);++coin){
for(ll i{0};i<max_n;i++)dp[i]=ll_min;
dp[0]=0; // 注意第0个点是能到达的reachable
2024-10-11 09:02:47 +00:00
```