摘要: 数据不能回滚: SHOW VARIABLES LIKE 'autocommit'; //查看是否自动提交 set autocommit=OFF; //关闭自动提交alter table TRIPLEG engine=innodb; //设置当前表的引擎为 innodb 更改有外键约束的数据: 方式一 阅读全文
posted @ 2022-10-31 22:50 Swelsh-corgi 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 题意:给你n个数,q次询问,问你能否具有满足和为s的序列,再求其有多少种和时需要使用m i d = m a x + m i n > > 1 来寻找有多少种和。 思路:手动模拟一下有点像线段树建树的过程,那就按照线段树来写,把线段树建树的过程改动一下,求出所有可能的序列的和,然后标记 ,询问的时候看看 阅读全文
posted @ 2021-01-25 13:02 Swelsh-corgi 阅读(49) 评论(0) 推荐(0) 编辑
摘要: 首先知道公式: 1、gcd(a1,a2,a3,a4……)=gcd(a1,gcd(a2,a3,a4……))2、gcd(a1,a2) = gcd(a1 , a2-a1) 推一下结论最后预处理一下 tp = gcd (a2 ​− a1​, ... , an ​− an−1​), 最后输出 gcd(a1​ 阅读全文
posted @ 2021-01-21 22:23 Swelsh-corgi 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 题意:有一个长度为n,只包含+ 和 -的字符串,+表示+1,-表示-1,x初始为0,有q次询问,每次询问输入一个区间表示该区间的符号忽略,问执行剩下的符号过程中出现几个不同的数 思路:线段树求区间最值,首先让 a[1]=0 ,然后利用 a数组进行构造线段树。这样就可以不用分类讨论了,只需要把在输入查 阅读全文
posted @ 2021-01-19 21:43 Swelsh-corgi 阅读(68) 评论(0) 推荐(1) 编辑
摘要: 思路:分一下奇偶,然后记忆化搜索(第一次写记忆化,卡了半天。。。) #include<bits/stdc++.h> using namespace std; const int N=1e5+10; typedef long long ll; map<ll,ll> f; ll x,y; ll solv 阅读全文
posted @ 2021-01-14 22:25 Swelsh-corgi 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 思路:如果是奇数数个商店,排序后选中间的那个为货仓位置。如果是偶数个,排序后选取 n / 2或者 n / 2 + 1位置的商店。 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int main() { int n; 阅读全文
posted @ 2021-01-12 17:02 Swelsh-corgi 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 题意:求连通块内点的个数 思路:BFS 跑一遍,看看能到达那些点,记录下来,然后统计一下 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int vis[25][25]; int dis[4][2]= {-1,0,1, 阅读全文
posted @ 2021-01-12 16:55 Swelsh-corgi 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 题意:给出一个非严格递减的子序列,需要完成 m 次操作,分为下列两种类型: 1> 1 x y:将区间 [ 1 , x ] 中的数进行 a[ i ] = max( a[ i ] , y ) 操作 2> 2 x y:给出一个权值 y,从 x 开始往 n 走,遇到 a[ i ] 如果满足 a[ i ] < 阅读全文
posted @ 2020-11-21 17:16 Swelsh-corgi 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 思路:首先有负权值,考虑SPFA,但是数据范围所以就得用双端优化过的SPFA。 #include<bits/stdc++.h> #include<cstring> #include<string.h> #include<cstdio> using namespace std; typedef lon 阅读全文
posted @ 2020-11-11 19:46 Swelsh-corgi 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 思路: 先整体看成全是0的一个线段树,然后按照题目要求进行修改和查询。 #include <iostream> #include <string.h> #include <string> #include<cstdio> #include <algorithm> #define ll long lo 阅读全文
posted @ 2020-11-11 19:31 Swelsh-corgi 阅读(124) 评论(0) 推荐(0) 编辑