摘要:
题意:给你n个数,q次询问,问你能否具有满足和为s的序列,再求其有多少种和时需要使用m i d = m a x + m i n > > 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 阅读全文
摘要:
思路:如果是奇数数个商店,排序后选中间的那个为货仓位置。如果是偶数个,排序后选取 n / 2或者 n / 2 + 1位置的商店。 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int main() { int n; 阅读全文
摘要:
题意:求连通块内点的个数 思路:BFS 跑一遍,看看能到达那些点,记录下来,然后统计一下 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int vis[25][25]; int dis[4][2]= {-1,0,1, 阅读全文
摘要:
题意:给出一个非严格递减的子序列,需要完成 m 次操作,分为下列两种类型: 1> 1 x y:将区间 [ 1 , x ] 中的数进行 a[ i ] = max( a[ i ] , y ) 操作 2> 2 x y:给出一个权值 y,从 x 开始往 n 走,遇到 a[ i ] 如果满足 a[ i ] < 阅读全文