2016 UESTC Training for Data Structures O – 卿学姐种美丽的花 树状数组+等差数列
O - 卿学姐种美丽的花 树状数组+等差数列 Source 2016 UESTC Training for Data Structures Problem O My Solution 树状数组+等差数列 更的时候 Ax = A0 + (x-x0)*(-1) 所以Ax求和并加上初始值就是新的val[x]…
O - 卿学姐种美丽的花 树状数组+等差数列 Source 2016 UESTC Training for Data Structures Problem O My Solution 树状数组+等差数列 更的时候 Ax = A0 + (x-x0)*(-1) 所以Ax求和并加上初始值就是新的val[x]…
B - 卿学姐与基本法 自己构建了一个和堆有点像的数据结构 Source 2016 UESTC Training for Data Structures Problem B My Solution 对很多个区间进行处理, 这里建一个结构体放存放区间,然后把区间…
E - 卿学姐与城堡的墙 树状数组求逆序对、离散化 Source 2016 UESTC Training for Data Structures Problem E My Solution 树状数组求逆序数 先对uy进行排序,如果a.uy != b.uy 那么uy大的在上面; 如果a.…
Q - 昊昊爱运动 II 线段树+延迟操作+bitset Source 2016 UESTC Training for Data Structures Problem Q My Solution 每次把一个区间变为一个定值 线段树+延迟操作+bitset 延迟操作,在查询或者改造的时候再…
500.Quacking string matches My Solution declare a string array; //"quack" when first meet 'q',add to the string which index is supposed to be as small sa possible, unless add to a empty stri…
M - 柱爷抢银行欢庆5.1special 递推 Source 2016 UESTC Training for Dynamic Programming My Solution 递推 k阶的图刚好是k+2阶的图的白色部分 - val[i][j]; 所以刚好dp[i][j] = getsum(i, j, i+k-1, j+k-1…
B. Beautiful Paintings greedy and bucket sort Source Codeforces Round #345 (Div. 2) B. Beautiful Paintings My Solution greedy and Bucket_sort. I use bool Bucket_sort[maxn][maxn] to store the…
被神选中的人 贪心 Source 每周一题 My Solution 这个题目看上去好像很难,好多烟雾弹,参透其玄机则瞬解。 其实只和m张梅花有关。n张红桃则无关,随便怎么整,或者说用方块A全部弑神在说。 然后: …
ZhangYu Speech 预处理、前缀和 Source 第七届ACM趣味程序设计竞赛第四场(正式赛)B My Solution 打表搞出前n项和;//像这样输入一次数据,然后n(n<1e6)次询问的,一般要预处理一下,来减少复杂度; 主要…
B - Banana Watch 预处理、前缀和 My Solution 用sum[i]表示1~i的和,然后,从1 ~ maxn 查找,第一次出现if((sum[i] %= n) == 0) {printf("%d", i); break;} 然后考虑到数据范围,所以第一发有maxn = 2000000 +…
Easy Problem 水题 Source The 14th UESTC Programming Contest Preliminary 在Contests里面的链接, E - Easy Problem 在Problems里面的链接, Easy Problem My Solution 在队友帮忙debug的情况下,自己还是…
H. A + B Strikes Back My Solution I am glad to come over the interesting problem.^_^ After 5 times of WA, I get a real test and Accepted. #include #include using namespace std…
AC Milan VS Juventus 分情况讨论 Source The 13th UESTC Programming Contest Preliminary The question is from here. My Solution 分情况讨论清楚就好,然后注意 a == b 的时候也是 No 把分类出来的区间理…
King's Order 数位dp Source The question is from BC and hduoj 5642. My Solution 数位dp 状态: d[i][j][k] 为处理完i 个字符 , 结尾字符为′a′+j , 结尾部分已重复出现了 k 次的方案数; 边界:d[1][j][…
Big Brother 二分图、最大匹配 Source 2015 UESTC Training for Graph Theory The question is from here. My Solution 最大匹配问题 匈牙利算法, (似乎也可以用它的改进版,Hopcroft-Karp算法) #includ…
King's Cake 模拟 优化 gcd source The question is from BC and hduoj 5640. My Solution //A really easy problem, I get a Runtime Error(STACK_OVERFLOW) first, then Time Limit Exceeded //next Runtime E…
被兵暴的沈宝宝 Catalan数、逆元 Source UESTC 1282 (CDOJ 1282) MySolution 卡特兰数经典模型 化简版的递推式是白书上看来的,f2 = f3 = 1 ,卡特兰数从 f3 开始 然后 f(i+1) = (4*i-6)*f(i)/i; 结合拓展欧几里得…
秋实大哥与妹纸 二叉堆(小根堆) Source 2015 UESTC Training for Data Structures The question is from here. My Solution Memory Limit: 1500/1500KB (Java/Others) 卡内存的题目,第一次遇到 (┬_┬) 维…
UVa 11997 K Smallest Sums 优先队列 打有序表 归并 The question is from here. My Solution 把每个数组排序以后打个 有序表 表1: A1 + B1 <= A1+B2 <= A1+B3 <= `````````` 表2: A2 + B1 <= `````` …
Lighting System Design dp : 线性结构上dp LIS The question is from here. My Solution 首先这个题目是要保持总灯泡数不变的,一定是换一个上去才可以,是在这个情况下money-saving,而不管energy-saving。所以把…