题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j-1],求f[n][n].C++代码: #include <iostream> using namespace std; ][]; int main() { cin >> n; ;i<=n;i++) f[i][] = f[][i] = ; ; i <= n; i ++) ;…
E. Pretty Song time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output When Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes m…
A. Maximum in Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An n × n table a is defined as follows: The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for…
题目传送门 /* 题意:有 n 个piles,第 i 个 piles有 ai 个pebbles,用 k 种颜色去填充所有存在的pebbles, 使得任意两个piles,用颜色c填充的pebbles数量之差 <= 1. 如果不填充某种颜色,就默认数量为0. 1. 贪心:如果个数之间超过k个,那么填充什么颜色都会大于1,巧妙地思维 详细解释:http://blog.csdn.net/haoliang94/article/details/43672617 2. 比较每种填充颜色在n组里使用最多和最少的…
题目传送门 /* 模拟递推水题 */ #include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <cstring> #include <string> #include <map> using namespace std; + ; const int INF = 0x3f3f3f3f; int a[MAXN][M…
Codeforces Round #116 (Div. 2, ACM-ICPC Rules) 代码 Codeforces Round #116 (Div. 2, ACM-ICPC Rules) A. Defragmentation 按颜色分配\(1\)到\(\sum_{i=1}^{m}{n_i}\)位置,那么可以得到\(t_i\)表示位置\(i\)最后占据位置\(t_i\),-1表示该位置为空. 那么会出现两种情况: \(t_1 \to t_2 \to \cdots \to \ {-1}\),即…
Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n 和你两场分赛的排名 x, y,问你最终名次最小和最大可能是多少. 思路: 以8人为例: x + y = 2,最小第一名,最大第一名:               1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1               x + y = 3,最小第一名,最大第二名.…
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given n strings consisting of lowercase Engl…
题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序列的长度是多少. 将相同颜色的下标存到对应颜色的容器中,比如ans[a[i]].push_back(i)就是将下标为i颜色为a[i]的数存到ans[a[i]]容器中. 对于每种颜色序列,尺取一下 在差距小于k的情况下取能取到的最大长度. //#pragma comment(linker, "/STA…
C. Letter Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/180/problem/C Description Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervou…
Letter time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was n…
题意 有nnn个点,每个点只能走到编号在[1,min(n+m,1)][1,min(n+m,1)][1,min(n+m,1)]范围内的点.求路径长度恰好为kkk的简单路径(一个点最多走一次)数. 1≤n≤109,1≤m≤4,1≤k≤min(n,12)1\le n\le 10^9,1\le m\le 4,1\le k\le min(n,12)1≤n≤109,1≤m≤4,1≤k≤min(n,12) 分析 直接考虑走路径的话不能判有没有走过,然后就把路径转化为一个序列,每次往里面插入新的点(神了).因为…
B. Strip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/problem/B Description Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right. Now Alexandra wants to split it into some pieces (p…
C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a…
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n fr…
题目链接: http://codeforces.com/problemset/problem/268/E E. Playlist time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 Manao's friends often send him new songs. He never listens to them right away. Instead, he compiles them into a play…
题目链接: http://codeforces.com/contest/464/problem/C J. Substitutes in Number time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends A…
D. Fox And Jumping 题目连接: http://codeforces.com/contest/510/problem/D Description Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at…
B. Maximum Submatrix 2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/375/B Description You are given a matrix consisting of digits zero and one, its size is n × m. You are allowed to rearrange its rows. What is…
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->...->3->...->...->p的最短路径. 题解: 这题dp的阶段性还是很明显的,相同的值得方格为同一个阶段,然后求从阶段1->2->3...->p的阶段图最短路. 初始化所有a[x][y]==1的格子为起始点到(x,y)坐标的距离. 方程式为dp[x1][y1…
题目链接: http://codeforces.com/contest/378/problem/E 题意: dota选英雄,现在有n个英雄,m个回合,两支队伍: 每一回合两个选择: b 1,队伍一ban掉一个英雄,或是跳过这个回合 p 1,队伍1选一个英雄 现在每个队伍都是最优决策,问最后队伍一的英雄实力和-队伍二的英雄实力和. 题解: 状压dp,决策要倒过来做,也就是dp出后面回合的决策的基础上设计出对自己当前回合对自己最有利的决策.. 注意:只有top m的英雄有可能被选,其他的都不可能被选…
题目链接:http://codeforces.com/problemset/problem/429/B 给你一个矩阵,一个人从(1, 1) ->(n, m),只能向下或者向右: 一个人从(n, 1) ->(1, m),只能向上或者向右.必须有一个相遇点, 相遇点的值不能被取到, 问两个人能得到的最大路径和是多少? dp[i][j]:表示从一个点出发的最大值:先预处理从(1,1) (1,m) (n,1) (n,m)四个点出发的4个dp最大值.然后枚举所有的点,但是这个点不能在边缘,考虑枚举点不够…
D. Spongebob and Squares Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/problem/D Description Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of…
E. LIS of Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/problem/E Description The next "Data Structures and Algorithms" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence.…
D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/problem/D Description While Duff was resting in the beach, she accidentally found a strange array b0, b1, ..., bl - 1 consisting of l positive integers. Th…
B. Modulo Sum Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/B Description You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such…
http://codeforces.com/contest/459/problem/E 不明确的是我的代码为啥AC不了,我的是记录we[i]以i为结尾的点的最大权值得边,然后wa在第35  36组数据 然后參考答案了,然后----网上一份题解 大意: 给出一个带权有向图,求经过的边权绝对上升的最长路径(可能是非简单路径,就可以能经过一个点多次)所包括的边数. 题解: 对边按权值排序后,从小到大搞. 设q[x]为已经搞过的边组成的以x点为终点的最长路径包括的边数. 设当前边e[i]为从u到v的边,…
C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talent…
题目:http://codeforces.com/problemset/problem/429/B 第一个人初始位置在(1,1),他必须走到(n,m)只能往下或者往右 第二个人初始位置在(n,1),他必须走到(1,m)只能往上或者往右 每个点都有个权值,要求两个人中间相遇一次且只有一次,相遇的那个点的权值不算,两个人的速度可以不一样,然后求出最大值是多少 思路:他的要求是相遇一次且只有一次,那么画几个图其实就只有两个情况了(这图是借了一位大佬的,[小声bb]) 既然知道了这个图分为了这四个区域,…
题目:https://codeforces.com/problemset/problem/711/C 题意:给你n,m,k,代表n个数的序列,有m种颜色可以涂,0代表未涂颜色,其他代表已经涂好了,连着一段是相同颜色的是一个连通块,求正好有k个连通块的最小花费 思路:首先每个位置有可能有m中颜色,而且要满足k个,我们我们可以推出所有情况 dp[n][m][k] n代表前n个数 m代表当前涂m色 k代表满足k个了 #include<cstdio> #include<cmath> #in…