C. Famil Door and Brackets 题目连接: http://www.codeforces.com/contest/629/problem/C Description As Famil Door's birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of roun…
题目链接: http://codeforces.com/contest/629/problem/C 题意: 长度为n的括号,已经知道的部分的长度为m,现在其前面和后面补充‘(',或')',使得其长度为n,且每个左括号都能找到右括号与它匹配. 题解: dp[i][j]表示长度为i,平衡度为j的合法括号序列的总数,这里平衡度定义是‘('比')'多多少个,或')'比’('多多少个. #include<iostream> #include<cstring> #include<cstd…
E. Famil Door and Roads 题目连接: http://www.codeforces.com/contest/629/problem/E Description Famil Door's City map looks like a tree (undirected connected acyclic graph) so other people call it Treeland. There are n intersections in the city connected b…
题目链接: http://www.codeforces.com/contest/629/problem/E 题解: 树形dp. siz[x]为x这颗子树的节点个数(包括x自己) dep[x]表示x这个节点的深度,从1开始(其实从什么开始都可以,我们这里用到的只是相对距离) 对于查询u,v,总共有三种情况: 1.u为公共祖先 设x为(u,v)链上u的儿子,则我们知道新边只能从非x子树的点(n-siz[x]连到以v为根的子树上的点(siz[v]) 则新边的总条数为(n-siz[x])*siz[v]…
Famil Door's City map looks like a tree (undirected connected acyclic graph) so other people call it Treeland. There are n intersections in the city connected by n - 1 bidirectional roads. There are m friends of Famil Door living in the city. The i-t…
Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the follow…
居然补完了 组合 A - Far Relative’s Birthday Cake import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner (new BufferedInputStream (System.in)); int n = cin.nextInt (); int[] col = new int[…
B. Far Relative's Problem 题目连接: http://www.codeforces.com/contest/629/problem/B Description Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of…
B. Far Relative’s Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them c…
A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a…
A. Far Relative's Birthday Cake time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to m…
A. Far Relative’s Birthday Cake time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to m…
D. Babaei and Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/D Description As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake. Simple cake is a cylinder of som…
A. Far Relative’s Birthday Cake time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to m…
题意:做蛋糕,给出N个半径,和高的圆柱,要求后面的体积比前面大的可以堆在前一个的上面,求最大的体积和. 思路:首先离散化蛋糕体积,以蛋糕数量建树建树,每个节点维护最大值,也就是假如节点i放在最上层情况下的体积最大值dp[i].每次查询比蛋糕i小且最大体积的蛋糕,然后更新线段树.注意此题查询的技巧!!查询区间不变l,r,才能保证每次查到的是小且最大体积. #include<iostream> #include<string> #include<algorithm> #in…
题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) #include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #include<set> #include<map> #include<vector> #includ…
水题 #include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #include<set> #include<map> #include<vector> #include<cstring> #include<stack> #include<cmath>…
A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> using namespace std; const int maxn = 105; char a[maxn][maxn]; int main (void) { int N;cin>>N; int cnt = 0, res = 0; for(int i = 0; i < N; i++){ cn…
题目链接: http://codeforces.com/problemset/problem/208/C C. Police Station time limit per test:2 secondsmemory limit per test:256 megabytes 问题描述 The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to…
B. Let's Play Osu! 题目连接: http://www.codeforces.com/contest/235/problem/B Description You're playing a game called Osu! Here's a simplified version of it. There are n clicks in a game. For each click there are two outcomes: correct or bad. Let us deno…
C. Chain Reaction 题目连接: http://www.codeforces.com/contest/608/problem/C Description There are n beacons located at distinct positions on a number line. The i-th beacon has position ai and power level bi. When the i-th beacon is activated, it destroys…
题目:https://codeforces.com/problemset/problem/977/F 题意:一个序列,求最长单调递增子序列,但是有一个要求是中间差值都是1 思路:dp,O(n)复杂度,我们想一下O(n^2)时的最长递增子序列,我们第二个循环要遍历前面所有的如果大于长度就加1,代表以这个数结尾的最长长度是多少, 因为中间差值不定,所以我们遍历整个循环,这个题设置中间差值只能是1,所以我们递推式就可以是   dp[i]=max(dp[i],dp[i-1]+1),用map来映射值即可…
C. Mahmoud and a Message 题目连接: http://codeforces.com/contest/766/problem/C Description Mahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was su…
题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemory limit per test256 megabytes 问题描述 The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the…
题目链接: http://codeforces.com/problemset/problem/621/E E. Wet Shark and Blocks time limit per test2 secondsmemory limit per test256 megabytes 问题描述 There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the inp…
题目链接: http://codeforces.com/problemset/problem/337/D D. Book of Evil time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements num…
C. Gerald and Giant Chess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/problem/C Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . The…
http://codeforces.com/contest/754/problem/C C. Vladik and chat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Vladik discovered a new entertainment — coding bots for social netwo…
D. Bad Luck Island Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/problem/D Description The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random i…
任意门:http://codeforces.com/contest/1114/problem/D D. Flood Fill time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a line of nn colored squares in a row, numbered from 11 to nn f…