C - Remembering Strings 思路:最关键的一点是字符的个数比串的个数多. 然后就能状压啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define y1 skldjfskldjg #define y2 skldfjsklejg using names…
C. Remembering Strings Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/543/problem/C Description You have multiset of n strings of the same length, consisting of lowercase English letters. We will say that those strings ar…
题目:https://codeforc.es/contest/1215/problem/E 题意:给你一个序列,你可以交换相邻的两个数,要达到一个要求,所有相同的数都相邻,问你交换次数最少是多少 思路:我们可以看到数的个数是1e5,数的范围只有20,很明显这个范围要干些什么,我们可以尝试去想一下状压,我们把数都弄到一起,然后一起状压,因为最后要变成是   xxxxyyyyyzzzkkka  的形态,所以我们可以把问题转化成 "一次放一个数", 这个思想很关键,经常在dp里面用到,这样的…
题意 林老师是一位大理石收藏家,他在家里收藏了n块各种颜色的大理石,第i块大理石的颜色为ai.但是林老师觉得这些石头在家里随意摆放太过凌乱,他希望把所有颜色相同的石头放在一起.换句话说,林老师需要对现有的大理石重新进行排列,在重新排列之后,对于每一个颜色j,如果最左边的颜色为j的大理石是第l块大理石,最右边的颜色为j的大理石是第r块大理石,那么从第l块大理石到第r块大理石,这些石头的颜色都为j. 由于这些大理石都比较重,林老师无法承受这些大理石的重量太久,所以他每次搬运只能交换相邻的两块大理石.…
题目链接 题意: 给定n个长度均为m的字符串 以下n行给出字符串 以下n*m的矩阵表示把相应的字母改动成其它字母的花费. 问: 对于一个字符串,若它是easy to remembering 当 它存在一个字母.使得这个字母在这一列是独一无二的. 要使得n个字符串都是easy to remembering 的最小花费. 第一个例子是把第一列的4个a中3个a改动成别的字母.所以花费为3. 思路: 显然是个状压dp,但须要一点转化. 首先得到一个结论: 对于某一列,设这一列的字母是 a,a,b,b,a…
C. Captains Mode 题目连接: http://codeforces.com/contest/377/problem/C Description Kostya is a progamer specializing in the discipline of Dota 2. Valve Corporation, the developer of this game, has recently released a new patch which turned the balance of…
传送门 E. Anya and Cubes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anya loves to fold and stick. Today she decided to do just that. Anya has n cubes lying in a line and numbered from 1…
原题链接:http://codeforces.com/contest/580/problem/D 题意: 给你一些一个有向图,求不超过m步的情况下,能获得的最大权值和是多少,点不能重复走. 题解: 令$dp[u][s]$为在节点u的时候状态是s的最大值.利用spfa的松弛操作来转移. 代码: #include<iostream> #include<cstring> #include<vector> #include<algorithm> #include&l…
Code: #include <cstdio> #include <algorithm> #include <cstring> #define setIO(s) freopen(s".in","r",stdin) #define inf (1<<22) #define maxn 30 using namespace std; char s[maxn][maxn]; int data[maxn][maxn],common…
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; ; const int INF = 0x3f3f3f3f;…