CodeForces 659F Polycarp and Hay】的更多相关文章

链接 Codeforces 659F Polycarp and Hay 题意 一个矩阵,减小一些数字的大小使得构成一个连通块的和恰好等于k,要求连通块中至少保持一个不变 思路 将数值从小到大排序,按顺序把与其相邻的加到并查集中.记录当前并查集中的个数,如果当前值能被K整除且总和超过了K,那么就可以以该点为中心输出了. 代码 #include <iostream> #include <cstdio> #include <vector> #include <stack…
有毒,自从上次选拔赛(哭哭)一个垃圾bfs写错之后,每次写bfs都要WA几发...好吧,其实也就这一次... 小白说的对,还是代码能力不足... 非常不足... 题目链接: http://codeforces.com/contest/659/problem/F 题意: n*m的格子,每个格子一个数,必须从格子中减去任意一个小于等于这个数的数. 给定数字k,要求: 剩下的格子数字和为k. 所有非零的格子的数字应该相同. 至少一个格子的数字没有改变. 含有非零数字的格子应该连通. 分析: 枚举每个能…
题目链接 遍历每个点, 如果这个点的值能被k整除并且k/a[i][j]后小于等于n*m, 那么就对这个点进行搜索. 将这个点加入队列, 将周围的所有大于等于这个点的值的点也加入队列. 不断重复, 直到队列空或者数量满足要求. 可以加一个额外的数组, 如果搜索的过程中, 这个值和a[i][j]相同, 那么就把这个格子标记, 减少额外的操作. #include <iostream> #include <vector> #include <cstdio> #include &…
并查集,$dfs$. 从大的数字往里加,每加一个数字合并一下连通块,判断连通块内数字个数是否够,以及k能不能被当前加入的数字整除.然后$dfs$一下构造答案. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<ve…
题目链接: F. Polycarp and Hay time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output The farmer Polycarp has a warehouse with hay, which can be represented as an n × m rectangular table, where n is t…
F. Polycarp and Hay 题目连接: http://www.codeforces.com/contest/659/problem/F Description The farmer Polycarp has a warehouse with hay, which can be represented as an n × m rectangular table, where n is the number of rows, and m is the number of columns…
题目链接: 题目 F. Polycarp and Hay time limit per test: 4 seconds memory limit per test: 512 megabytes input: standard input output: standard output 问题描述 The farmer Polycarp has a warehouse with hay, which can be represented as an n × m rectangular table,…
time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard output The farmer Polycarp has a warehouse with hay, which can be represented as an n × m rectangular table, where n is the number of rows, and m is th…
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented a…
题目链接:http://codeforces.com/contest/727/problem/F 题目大意:有n个问题,每个问题有一个价值ai,一开始的心情值为q,每当读到一个问题时,心情值将会加上该问题的价值.问题只能按顺序读.有m个询问,求当q=bi时,至少要删去多少个问题才能使得在任何时候心情值都>=0 参考这篇:http://blog.csdn.net/aufeas/article/details/53031439 解法一: 贪心 分别求出最多删去i个问题需要的初始心情值的最小值f[i]…