bellman-ford bellman acwing ford

AcWing 340. 通信线路

题目传送门:340. 通信线路 - AcWing题库 题目大致意思 对于一条路径,他的花费是,其经过的所以路线中花费最大的一条,你可以选择k条线,使其变为免费,求1到n的最小花费。 解题方法 本题可以用spfa加上dp来写。 对于同样是单源最短路,不可以用dijkstra的原因是:该题会将路径更改为 ......
线路 AcWing 340

山东大学考研机试--AcWing 3717. 整数序列

## 题目描述 很多整数可以由一连串的整数序列(至少两个数)相加而成,比如 25=3+4+5+6+7=12+13。输入一个整数 N,输出 N 的全部整数序列,如果没有则输出 NONE。 ## 输入格式 一个整数 N。 ## 输出格式 每行输出一个满足条件的整数序列。 序列内部元素从小到大排序。 优先 ......
整数 序列 AcWing 大学 3717

关于 AcWing 网站及延伸

--AcWing 网站 https://www.acwing.com/ AcWing 是一个在线编程学习平台,提供了各种算法和工程课程,以及丰富的题库和活动。你可以在 AcWing 上学习编程知识,刷题练习,参加比赛,或者和其他同学交流。 AcWing 的名字来源于英文单词 “acwing”,意思是 ......
AcWing 网站

acwing 智商药

题目链接:5046. 智商药 - AcWing题库 首先考虑dfs 不用想肯定超时 过了10/17个测试点 代码 1 #include<bits/stdc++.h> 2 3 using namespace std; 4 typedef pair<int,int> PII; 5 typedef lon ......
智商 acwing

Bellman–Ford 算法

[TOC] # Bellman-Ford 算法 贝尔曼-福特(Bellman–Ford)算法是一种基于松弛(relax)操作的最短路径算法,可以求出**有负权的图**的最短路径,并可以对最短路径不存在的情况进行判断。 # 记号 为了方便叙述,这里先给出下文将会用到的一些记号的含义。 - $n$ 为图 ......
算法 Bellman Ford

AcWing,第110场周赛 智商药

## [AcWing,第110场周赛 智商药](https://www.acwing.com/problem/content/5049/) tag:树状数组, 线段树,二维数点(因为有 $r$ 这个限制,算吧) 分析:当吃药时 $r$ 时,只有 $[l, r - 1]$ 的方法对答案有贡献,不难看出 ......
智商 AcWing 110

AcWing,第108场周赛T3 拼接数组

## [AcWing,第108场周赛T3](https://www.acwing.com/problem/content/description/5043/) 前置知识:[P1115 最大子段和](https://www.luogu.com.cn/problem/P1115) 的dp和线段树作法 分 ......
数组 AcWing 108

AcWing 3662. 最大上升子序列和

## [$AcWing$ $3662$. 最大上升子序列和](https://www.acwing.com/problem/content/description/3665/) ### 一、题目描述 给定一个长度为 $n$ 的整数序列 $a_1,a_2,…,a_n$。 请你选出一个该序列的 **严格 ......
序列 AcWing 3662

算法刷题笔记(一)(1) Acwing.153. 双栈排序

## Solution https://www.acwing.com/problem/content/155/ ##### **二分图,染色,贪心 O(n^2)** 性质 > 当且仅当i a[i]>a[k] 那么j和j之后的元素一定在i之后出栈,所以当序列遍历到j时,一定可以让i出栈,进而j就可以进 ......
算法 笔记 Acwing 153

Acwing 4440 照相

# Acwing 4440 照相 ### [原题指路](https://www.acwing.com/problem/content/4443/) 因为序列长为偶数,考虑将牛进行两两分组 ![](https://img2023.cnblogs.com/blog/3163322/202306/3163 ......
Acwing 4440

【acwing】Trie字符串统计

Trie树 学习感受 相比于之前学习的kmp匹配算法,Trie树的实现还是非常好理解的。(kmp算法太难了orz) 从直观的模拟过程来看,trie树就像一颗树一样,从上(根节点)到下(叶节点)有序串联起来组成一个字符串。 每一个额外标记结束的位置表示字符串的结束,通过计算标记数即可指导一共有多少该字 ......
字符串 字符 acwing Trie

前缀和 (Acwing_796 子矩阵的和)

[题目](https://www.acwing.com/activity/content/problem/content/830/) ![S[i,j]](https://img2023.cnblogs.com/blog/3096145/202305/3096145-20230529172938685 ......
前缀 矩阵 Acwing 796

Acwing 798.差分矩阵(模板)

[题目](https://www.acwing.com/problem/content/800) ``` #include using namespace std; const int N = 1010; int n, m, q; int a[N][N], b[N][N]; void insert( ......
矩阵 模板 Acwing 798

AcWing906.区间分组

# 题目详情 ![](https://img2023.cnblogs.com/blog/2826001/202305/2826001-20230523165112258-327765903.png) # 知识点 区间贪心 还是按照某端点值进行排序 从提出算法->验证算法有效性 # 思路 #### 做 ......
区间 AcWing 906

Bellman-Ford 单源最短路

单源最短路,顾名思义,就是从一个起点到其余点的最短距离 Bellman-Ford算法的思路是进行至多n-1轮的更新,每次遍历所有的边,进行松弛操作d[v]=min(d[v],d[u]+w); Bellman-Ford算法可以处理有负边权的图,也可以判负环,只要在第n轮还能进行松弛操作,说明存在负环 ......
Bellman-Ford Bellman Ford

AcWing 99. 激光炸弹

......
炸弹 激光 AcWing 99

AcWing905.区间选点

# 题目详情 ![](https://img2023.cnblogs.com/blog/2826001/202305/2826001-20230522193234818-1657453835.png) # 知识点 区间贪心 **为什么叫贪心呢?** ——**短视**,每次只是在看眼前的东西,在眼前的 ......
区间 AcWing 905

AcWing901. 滑雪(python)

# 题目详情 ![](https://img2023.cnblogs.com/blog/2826001/202305/2826001-20230522162406198-673075706.png) ![](https://img2023.cnblogs.com/blog/2826001/20230 ......
AcWing python 901

AcWing900.整数划分(python)

# 题目详情 ![](https://img2023.cnblogs.com/blog/2826001/202305/2826001-20230522152834670-504842011.png) # 知识点 **计数类DP** 分析题目,k个数是默认排好序的,也就是说,对于划分我们的考虑是无序的 ......
整数 AcWing python 900

AcWing 777. 字符串乘方

AcWing 777. 字符串乘方 1. 地址 https://www.acwing.com/problem/content/779/ 2. 题解 #include <iostream> #include <cstdio> using namespace std; /* 算法思路: 通过本题性质,我 ......
乘方 字符串 字符 AcWing 777

AcWing 776. 字符串移位包含问题

AcWing 776. 字符串移位包含问题 1. 地址 https://www.acwing.com/problem/content/778/ 2. 题解 #include <iostream> #include <cstdio> #include <string> #include <algori ......
字符串 字符 AcWing 问题 776

AcWing 771. 字符串中最长的连续出现的字符

AcWing 771. 字符串中最长的连续出现的字符 1. 地址 https://www.acwing.com/problem/content/description/773/ 2. 题解 #include <iostream> #include <cstdio> #include <string> ......
字符 字符串 AcWing 771

Acwing周赛102

倍增 这是一道简单数论题 using namespace std; typedef long long LL; const int N = 1e5 + 10; int a[N], n; int div(int x) { if(x % 2 == 0) while(x % 2 == 0) x /= 2; ......
Acwing 102

AcWing 770. 单词替换

AcWing 770. 单词替换 1. 地址 https://www.acwing.com/problem/content/772/ 2. 题解 #include <iostream> #include <cstdio> #include <sstream> using namespace std; ......
单词 AcWing 770

POJ2739 Sum of Consecutive Prime Numbers&&Acwing4938 连续质数之和

方法:单调队列 为什么是单调队列?因为这里让我们求连续的质数和,我们可以利用欧拉筛来维护质数,再利用单调队列来维护连续的质数。 代码( ~~POJ 不支持 C++ 11 差评~~): #include<cstdlib> #include<cstring> #include<cstdio> #incl ......
质数 之和 Consecutive amp Numbers

acwing 4645. 选数异或

输出yes no yes no 题意分析,给一串数组,再在每次提问时给出一个区间,l,r; 求l,r区间内是否存在两个数,两数异或后值为给出的x; 已知a^b=x-->a^x=b; 思路:1,把每个数异或x,存在另一个数组(b)里,暴力搜索,看区间内b数组内数字是否有等于a数组内数字,TLE 2.记 ......
acwing 4645

AcWing 3549. 最长非递减子序列

$AcWing$ $3549$. 最长非递减子序列 一、题目描述 给定一个长度为 $n$ 的数字序列 $a_1,a_2,…,a_n$,序列中只包含数字 $1$ 和 $2$。 现在,你要选取一个区间 $l,r$,将 $a_l,a_{l+1},…,a_r$ 进行翻转,并且使得到的新数字序列 $a$ 的最 ......
序列 AcWing 3549

AcWing 1209. 带分数

1-暴力解法 思考1:暴力列举出1~9的全排列,之后再将这些数字按照一定规则相加,最后将结果与n比较。全排列好写,但相加的规则不好写,而且太暴力了,估计会超时。 /* AcWing 1209. 带分数 00.最暴力的写法 1.枚举全排列 2.枚举位数(枚举a和b,可算出c) 3.直接算出n,判断等式 ......
带分数 AcWing 1209

AcWing 756. 蛇形矩阵

AcWing 756. 蛇形矩阵 1. 地址 https://www.acwing.com/problem/content/description/758/ 2. 题解 #include <iostream> #include <cstdio> using namespace std; //通过四个 ......
蛇形 矩阵 AcWing 756

AcWing 754. 平方矩阵 II

AcWing 754. 平方矩阵 II 1. 地址 https://www.acwing.com/problem/content/756/ 2. 题解 #include <iostream> #include <cstdio> #include <cmath> using namespace std ......
矩阵 AcWing 754 II