codeforces D. Painting The Wall】的更多相关文章

http://codeforces.com/problemset/problem/399/D 题意:给出n和m,表示在一个n*n的平面上有n*n个方格,其中有m块已经涂色.现在随机选中一块进行涂色(如果已经涂色跳过,也消耗时间),消耗1个步骤.终止条件为每行每列都有至少有一块瓷砖被涂色.问说涂成满意的情况需要时间的期望. 思路:把整个方格分成四部分,如果选择左上角上的一块,那么行和列都将被涂上一个:右上角的话,行被涂上一个,列不变:左下角的话,行不变,列被涂上一个:右下角,行列都不变. 状态转移…
B. Painting The Wall time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output User ainta decided to paint a wall. The wall consists of n2 tiles, that are arranged in an n × n table. Some tiles are p…
                                                                               D. Painting The Wall   User ainta decided to paint a wall. The wall consists of n2 tiles, that are arranged in an n × n table. Some tiles are painted, and the others are n…
B. Painting The Wall time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output User ainta decided to paint a wall. The wall consists of n2 tiles, that are arranged in an n × n table. Some tiles are p…
题目链接:http://codeforces.com/problemset/problem/509/B 题目意思:有 n 个piles,第 i 个 piles有 ai 个pebbles,用 k 种颜色去填充所有存在的pebbles,使得任意两个piles,用颜色c填充的pebbles数量之差 <= 1.如果不填充某种颜色,就默认数量为0. 这样说还是比较难理解吧---以第三组数据为例: 5 43 2 4 3 5 YES1 2 31 31 2 3 41 3 41 1 2 3 4 第2个 pile…
http://codeforces.com/contest/448/problem/C 题意:给你n宽度为1,高度为ai的木板,然后用刷子刷颜色,可以横着刷.刷着刷,问最少刷多少次可以全部刷上颜色. 思路:dp[i][j] 表示在第i列以后的木板都已刷完且第j列的木板是横着刷的,最少需要的次数.如果a[i]>=a[j]的情况,比较再竖着刷一次和横着刷哪一个情况次数少. #include <cstdio> #include <iostream> #include <cst…
Description Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent planks have no gap b…
洛谷 Codeforces 建议阅读这篇博客作为预备.无耻地打广告 思路 与bzoj4025很相似,思路也差不多,可以看上面那篇博客. 仍然是用二分图的充要条件:没有奇环. 然而这题难在每条边的存在时间不固定,无法一开始知道. 可以每次在加入这条边的时间点判断能否成功修改,确定接下来一段时间它的颜色是什么. 具体见代码. 代码 #include<bits/stdc++.h> namespace my_std{ using namespace std; #define pii pair<i…
题目链接:http://codeforces.com/contest/448/problem/C 题目大意:n个1* a [ i ] 的木板,把他们立起来,变成每个木板宽为1长为 a [ i ] 的栅栏,现在要给栅栏刷漆,刷子宽1,刷子可以刷任意长,每次只能横着刷或者竖着刷,问最少需要刷几次?解题思路:参考了这里(https://blog.csdn.net/qq_24451605/article/details/48492573)首先我们能够想到,如果横着刷,为了得到最优解,当前刷的位置的下面也…
题目链接:https://codeforces.com/contest/1132/problem/C 题意: 栅栏有 $n$ 个节,有 $q$ 个人可以雇佣来涂栅栏,第 $i$ 个人可以涂第 $l_i$ 节到第 $r_i$ 节. 但是现在预算紧张,所以只能雇佣 $q-2$ 个人,你想确认雇佣哪 $q-2$ 个人使得涂色栅栏的节数最大. 题解: 首先看到 $n$ 的范围,就可以想到大概可以枚举第一个不雇佣的人再枚举第二个不雇佣的人,时间复杂度在 $O(n^2)$ 左右. 先假定第一个不雇佣的人是第…