Codeforces 392 B Blown Garland】的更多相关文章

题意:输入是由连续的RYGB和字符!组成的字符串,R代表红灯,Y代表黄灯,G代表绿灯,B代表蓝灯.简而言之,就是给定的字符串保证了下标对4取余相同的灯颜色都相同,但是有的地方为‘!’代表这个灯坏了,然后分别输出坏了的红.蓝.黄.绿灯的数量. 分析:因为下标对4取余相同的灯颜色都相同,所以确定了前四个灯的颜色,后面的灯都是前四个灯颜色的不断循环,两个map映射一下就可以了. #include<bits/stdc++.h> #define Min(a, b) ((a < b) ? a : b…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland. Now he has a goal to…
http://codeforces.com/problemset/problem/758/B 题意:给出一个字符串,每4个位置对应一个颜色,如果为‘!’的话,代表该灯泡是坏的,问最后每个颜色坏的灯泡的数目. 思路:题意实在挺难懂的(可能我到现在还没看懂).看样例看了好久才看出来.例如最后一个样例“!GB!RG!Y!”:可以拆分成"!GB!”,"RG!Y","!",R只在第一个位置出现,说明R是在第一个位置的,以此类推,G是在第二个位置,B是在第三个位置,Y…
B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.…
B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.…
题目链接:http://codeforces.com/contest/758/problem/B 题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少. 分析:就是要找出这个链子是那个部分.那么就有4!种可能. #include <bits/stdc++.h> using namespace std; ][] = { "BGRY", "BGYR", "BRGY", "BRYG"…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland. Now he has a go…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
A. New Year Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood,…
传送门: 解题思路: 要求相邻两行小球颜色集合不同,并且限制行内小球相邻不同. 由此可得:每行小球排列都是独立与外界的, 所以答案应该是对于所有行的颜色集合分类,在将行内的答案乘到上面. 先考虑如何分类: 我们可以确定对于每行所取的颜色种类$x=|S|$, 若相邻两行$i,j$,其$x_i!=x_j$,那么一定是合法的,有$C_m^x$种选择方法. 而对于相邻两行$x_i=x_j$,对于行$i$的一种方案,只有一种可能使得$S_i=S_j$, 所以可以使用容斥来计算答案 综上所述,按照每行的颜色…
题意:老师点名顺序规则如下:第1排,第2排,……,第n-1排,第n排,第n-1排,……,第2排,第1排,第2排,……,第n-1排,第n排,……对于每排都是从左到右依次点名,问点名k个人后,所有人中最多的点名次数,最少的点名次数,以及位于x排y列处的同学的点名次数. 分析: 1.由于k很大,将第1排,第2排,……,第n-1排,第n排,第n-1排,……,第2排看成一个循环. 2.这个循环中有2*(n-1)*m个人,注意当n=1时,这个循环中有m个人,将这个循环人数记为tmp. 3.利用k/tmp,算…
A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citi…
B. Blown Garland time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.…
赛前任务 tags:任务清单 前言 现在xzy太弱了,而且他最近越来越弱了,天天被爆踩,天天被爆踩 题单不会在作业部落发布,所以可(yi)能(ding)会不及时更新 省选前的练习莫名其妙地成为了Noip前的杂题训练,我也很无奈啊 做完了的扔最后,欢迎好题推荐 这么多题肯定是完不成了,能多做一道是一道吧 DP yyb真是强得不要不要的辣:http://www.cnblogs.com/cjyyb/category/1036536.html [ ] [SDOI2010]地精部落 https://www…
题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard output You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The colo…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
题目链接:http://codeforces.com/contest/767/problem/C 问能否将一棵带点权的书分成点权$3$块,求任意方案. 其实考虑一棵以$x$为根的子树权值为${\frac{1}{3}\sum val[i]}$之后它就一定要作为单独的一块了,那么DFS一遍即可. #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<…
As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent New Year Tree must be decorated with a good garland. Edward has lamps of m colors and he wants to mak…
原题地址:http://codeforces.com/contest/758/problem/F F. Geometrical Progression time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output For given n, l and r find the number of distinct geometrical pro…
题目链接:http://codeforces.com/contest/767/problem/C 题解:类似于提着一串葡萄,用剪刀剪两条藤,葡萄分成了三串.问怎样剪才能使三串葡萄的质量相等. 首先要做的就是统计葡萄的总质量tot.之后就是找到两子串质量为(tot/3)的葡萄(如果除不尽,则必定找不到),那么剩下的就是dfs搜索了. 我一开始的做法是先建一棵记录子树质量和的树,然后再从上往下dfs,如果找到了,就把它剪掉.后来发现被剪掉的那一串可能就含有两串质量为(tot/3)的葡萄(这里质量 可…
C. Garland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Once at New Year Dima had a dream in which he was presented a fairy garland. A garland is a set of lamps, some pairs of which are…
[题目链接]:http://codeforces.com/contest/767/problem/C [题意] 一棵树; 树上的每个节点都有一个权值; 让你把一棵树切掉两条边; 然后把这棵树分成了3个部分; 要求这3个部分,每个部分的权值和相同; 即sum1=sum2=sum3 [题解] 树形DP; 一开始累加所有节点的权值和sum; 如果不是3的倍数则直接输出无解; 用cnt[x]记录x节点下方的子树和(权值和); 假设dfs到了第x个节点 考虑两种情况; ① 有两个节点y,z; 且sum/3…
题目链接: http://codeforces.com/problemset/problem/140/E 题意: 圣诞树上挂彩球,要求从上到下挂\(n\)层彩球.已知有\(m\)种颜色的球,球的数量不限. 要求结果对\(p\)取模.然后给你\(n\)个数,表示第 \(i\) 根绳长 \(l_i\),也就是要挂 \(l_i\) 个球. \(1.\)要求每根绳上相邻彩球颜色不同. \(2.\)相邻的绳子上挂的彩球种类不能相同. 题解: 我们先解决子问题,先考虑第 \(i\) 层上能放多少个球,\(a…
题目链接:http://codeforces.com/contest/758/problem/C 题意:给定N*M矩阵的教室,每个位置都有一个学生,Sergei坐在[X,Y],然后老师会问K个问题,对于行而言问的顺序是从第一行,第二行...第N行,第N-1行...第二行,第一行然后重复.对于列而言问的顺序都是从左到右,现在问你最后问完K个问题后,被提问的最多的同学的次数是多少,被提问的最少的同学的次数是多少,Sergei被提问的次数是多少. 思路:由于k的范围太大,所以不能一个一个模拟,考虑下循…
题目链接:http://codeforces.com/contest/758/problem/B 题意:给定n个点灯的情况,灯只有四种颜色RBGY,然后如果某个灯坏了则用'!'表示,现在要求将坏的灯(即'!'的位置)用其他新的灯来替换(新灯只有前面描述的四种颜色),并且要满足最后的灯序列每连续四个位置的灯的颜色都不一样(即分别是给定的四种颜色,顺序任意).问最后要用每种颜色的灯的数目.题目保证输入一定合法,即一定存在一个符合条件的序列 思路:因为每连续四个位置要满足颜色不一样的要求,所以我们可以…
题目链接:http://codeforces.com/contest/758/problem/A 题意:给定N个城市的福利,国王现在想让每个城市的福利都一致.问最少需要花多少钱使得N个城市的福利值都一致. 思路:找到N个城市的福利的最大值,然后所以城市按照这个最大值来补即可. 即N*max(val[i])-sigma(val[i])  [1<=i<=N] import java.io.PrintWriter; import java.util.*; public class Main { pu…
题目连接:https://codeforces.com/contest/1283/problem/F 题意:一根电线连接着两个点,这两个点分别代表着两个灯,灯有自己的编号i,其亮度是2 ^ i,每根电线的两个灯分别为主灯和副灯,电源从主灯来,电流向副灯.最开始有一个源点灯,所有的电源从此处流入,对于每根电线,定义其重要性为 :切断这根电线后不能通电的所有灯的亮度之和.首先题目按电线的重要性给出n-1条电线的主灯编号,让你从大到小输出每条电线所连接的两个灯的序号(无前后差别) 题解:首先,题目的所…