【BZOJ】1452: [JSOI2009]Count】的更多相关文章

http://www.lydsy.com/JudgeOnline/problem.php?id=1452 题意:n×m的矩阵上每个点有个颜色,现在有q个操作:1 x y c 将点(x,y)的颜色改为c:2 x1 x2 y1 y2 c 询问矩阵x1y1-x2y2颜色为c的格子数目 #include <bits/stdc++.h> using namespace std; const int N=301; int n, m; int S[101][N][N], col[N][N]; void up…
[算法]博弈论+二分图匹配(最大流) [题解]方格图黑白染色得到二分图, 二分图博弈:当起点不属于某个最大匹配时,后手必胜. 问题转化为那些点不属于某个最大匹配. 先找到一个最大匹配,非匹配点加入答案. 假设一个匹配点要解放成为非匹配点,则与其匹配的点必须去匹配另一个点.如果另一个点也是匹配点,则其对面又要去找另一个点. 最终得到结论,一个匹配点的解放,必须有一个非匹配点进入最大匹配. 那么从S一侧的非匹配点出发,沿着“非匹配边-匹配边”的路径走,途中经过的S一侧的匹配点都可以被解放出来. 从T…
[算法]数位DP [题解] 记忆化搜索 #include<cstdio> #include<algorithm> #include<cstring> #define ll long long using namespace std; ll A[],B[],f[][],a[],p[]; ll dfs(ll* A,ll h,bool limit,bool pre) { ); ]!=-&&!pre) { ;i<=;i++)A[i]+=f[h][i]; ]…
题目 传送门:QWQ 分析 蒟蒻不会数位dp,又是现学的 用$ dp[i][j][k] $ 表示表示长度为i开头j的所有数字中k的个数 然后预处理出这个数组,再计算答案 代码 #include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[][][], ans[], b[], sum[]; int solve(ll x,ll d){ ; ll bef=x; ){ b[++len]=x%; } ;i<len…
1452: [JSOI2009]Count Description Input Output Sample Input Sample Output 1 2 HINT Source 题解:设定C[101][N][N] 树状数组上价值为val的lowbit数组 //meek ///#include<bits/stdc++.h> #include <iostream> #include <cstdio> #include <cmath> #include <…
为每一个权值开一个二维树状数组. ------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream>   #define rep(i, n) for(int i = 0; i < n; ++i) #define Rep(i ,n…
http://www.lydsy.com/JudgeOnline/problem.php?id=3052 题意:n个带颜色的点(m种),q次询问,每次询问x到y的路径上sum{w[次数]*v[颜色]},可以单点修改颜色.(n, m, q<=100000) #include <bits/stdc++.h> using namespace std; const int N=100005, M=100005; typedef long long ll; inline int getint()…
http://www.lydsy.com/JudgeOnline/problem.php?id=3319 题意:给一棵n节点的树(n<=1e6),m个操作(m<=1e6),每次操作有两种:1.查询u到根的第一条黑边的编号.2.将u到v的路径全部染成黑色 #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream>…
http://www.lydsy.com/JudgeOnline/problem.php?id=3319 以为是模板题就复习了下hld............................. 然后nlg^2n被tle成翔了.............................. 然后看题解QAQ,,,这... 神题做法...待会再写...(upd:[BZOJ]3319: 黑白树) tle的hld: #include <cstdio> #include <cstring> #i…
[BZOJ]1013: [JSOI2008]球形空间产生器sphere 题意:给n+1个n维的点的坐标,要你求出一个到这n+1个点距离相等的点的坐标: 思路:高斯消元即第i个点和第i+1个点处理出一个式子,这样n+1个点正好有n个系数的n元变量,即可求解. 式子:Σ( (a[i][j] - x[j])^2 )  = Σ( a[i+1][j] - x[j])^2 ) =>   Σ( x[j]*[2*(a[i+1][j]-a[i][j])] ) = Σ(a[i+1][j]*a[i+1][j] - a…