随笔分类 - hdu
摘要:2015 Multi-University Training Contest 5 1004当时全场没有队伍通过的一道题,此题状态构造的甚是巧妙题意:n个人,每次从存活的人中等概率选出一个人去攻击场上其他人,被攻击者存活的概率相等 且由题目给出,选出的人出局。求一个人被攻击k次之后出局(被选出来攻击其...
阅读全文
摘要:题意:求一个动态的非递减序列中,下标 mod 5 == 3的元素和,可以向序列中添加和删除某些元素,且序列的单调性不变。保证在任意时间 序列中不会存在两个相同元素。保证输入合法思路:保证在任意时间 序列中不会存在两个相同元素,也就说明如果将所有的值都插入序列中,每个值对应的位置是唯一的。所以将操作的...
阅读全文
摘要:题意:一列经过1000000个站点的火车上最多同时乘坐 K 个人,有 Q 个乘客按照题目给出的顺序去买票,输出所有购票成功的乘客做法:RMQ线段树 + 区间更新 1 #include "bits/stdc++.h" 2 using namespace std; 3 #define lson l...
阅读全文
摘要:2015Multi-UniversityTrainingContest3 1001 1 #include "bits/stdc++.h" 2 using namespace std; 3 #define M 100010 4 #define lson l,m,rt>1; 70 Bui...
阅读全文
摘要:// 题意:从长度为 N 的字符串中删除 M 个字符,使得生成的新串的字典序最小// 思路:反向构造 1 #include "bits/stdc++.h" 2 using namespace std; 3 const int MAXN = 100010; 4 int n; 5 char ans[MA...
阅读全文
摘要:// M == 0 有trick... N < 2 也有trick...... 1 #include"iostream" 2 #include"cstdio" 3 #include"cstring" 4 #include"map" 5 using namespace std; 6 int...
阅读全文
摘要:// 统计 s1 的子序列中是 s1 和 s2 的最长公共子序列的个数 1 #include "bits/stdc++.h" 2 using namespace std; 3 int T; 4 char s1[1010], s2[1010]; 5 int dp[1010][1010]; 6 long...
阅读全文
摘要:// 判断出(田忌)的必胜局面和必败局面,则可以容易的得到决策方案// 若没有明显的必胜局面和必败局面,则使用田忌赛马的策略 1 #include "bits/stdc++.h" 2 using namespace std; 3 int N; 4 int v1[1010], v2[1010]; 5 ...
阅读全文
摘要://这题的数据是不是有问题... 不考虑宝藏一个也拿不到也能AC... 1 #include "bits/stdc++.h" 2 using namespace std; 3 const int INF = 0x3f3f3f3f; 4 int T; 5 int N, M; 6 int m...
阅读全文
摘要:1 #include "bits/stdc++.h" 2 using namespace std; 3 int T; 4 5 int dp[40000]; 6 int totene[40000]; 7 8 int N, E; 9 int val[20], ene[20], cond[20];1...
阅读全文
摘要://2015.7.16 首A 1 #include "bits/stdc++.h" 2 using namespace std; 3 int T; 4 int N; 5 char subject[20][110]; 6 int deadline[20], spend[20]; 7 int dp[40...
阅读全文
摘要:戳这里:3401题意:给出第i 天的股票买卖价格(APi,BPi),以及每天股票买卖的数量上限(ASi,BSi),要求任两次交易需要间隔 W 天以上,即第 i 天交易,第 i + W + 1 天才能再交易,求最多能赚多少钱思路:dp[i][j] = max(dp[i - 1][j], max(dp[...
阅读全文
摘要:戳这里:2844//复习一下背包问题//题意:告知你 N 中硬币的面值和数量,求能组成多少不同的面额,面额限制在区间 [1, M] 中//思路:用背包覆盖一边,取硬币的空间为它自身的价值,则当 dp[i] == i 时,说明空间为 i 的背包背填满,即可以组成面额为 i 的情况 1 #include...
阅读全文
摘要:戳这里:HDU 4054//复习一下 cin.getline() 的用法 1 #include "bits/stdc++.h" 2 using namespace std; 3 char str[5000]; 4 5 char Change(char c) 6 { 7 if('A' <= ...
阅读全文
摘要:戳这里:HDU 4034//思路:根据题意可得,若 mat[i][j] > mat[i][k] + mat[k][j] 则无解;若mat[i][j] == mat[i][k] + mat[k][j] 且分别对应 i->j i->k k->j 的三条有向边,则可以删掉i->j 有向边使得原来 i 到 ...
阅读全文
摘要:戳这里:HDU 4020//为方便处理输入信息而对其进行 排序 预处理,算是经典的离线操作方法了 1 #include "bits/stdc++.h" 2 using namespace std; 3 int T, N, M, Q; 4 struct Ads 5 { 6 int U, C, ...
阅读全文
摘要:戳这里:HDU 4001//题意:有三种积木,第0种只能放在长和宽都严格小于它的积木上,第1种 只能放在长和宽都小于等于它 且 面积小于它的积木上,第2种 只能放在长和宽都小于等于它的积木上,dp求积木的最高高度。 1 #include "bits/stdc++.h" 2 using namespa...
阅读全文
摘要://1403思路:字符串的任何一个子串都是这个字符串的某个后缀的前缀,则求A和B的最长公共子串等价于求A的后缀和B的后缀的最长公共前缀的最大值。做法:将第二个字符串写在第一个字符串后面,中间用一个没有出现过的字符隔开,再求这个新的字符串的后缀数组。 1 #include "bits/stdc++.h...
阅读全文
摘要://3407//题意:给一段字符串,由状态转换图画出状态转换表 1 #include "bits/stdc++.h" 2 using namespace std; 3 char str[10010]; 4 struct DfaNode { 5 char ch; 6 int...
阅读全文
摘要://3555//题意:统计 1 到 n 中包含 49 的数的个数 1 #include "bits\stdc++.h" 2 using namespace std; 3 __int64 dp[22][3]; 4 5 int main() 6 { 7 int i; 8 dp[0][0...
阅读全文

浙公网安备 33010602011771号