感觉这题还可以 因为总空间比输入数量 不知高到哪里去了 ,所以完全不需要考虑放不下的问题 从贪心的角度考虑,如果要使相差数量巨大的\(b\)和\(w\)能够成功放下来,应该使这些方块尽量分散(似乎有点抽象) 来一发图解 作者因为太懒于是决定直接以B表示黑色,W表示白色 假设有一组方块拼成了一个正方形,如图 BWB WBW BWB 那么在不改变白块数量的情况下,最多还能加\(4\)个黑块,分别连在四个白块旁边 但是如果拉成直线,如图 BWBWBWBWB 发现可以在两边总共加\(8\)个黑块了,因为…
E. Connected Component on a Chessboard time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given two integers b and w. You have a chessboard of size 109×109 with the top left cell at (1;1)…
传送门 题意: 给你一个黑白相间的1e9*1e9的棋盘,你需要从里面找出来由b个黑色的格子和w个白色的格子组成的连通器(就是你找出来的b+w个格子要连接在一起,不需要成环).问你可不可以找出来,如果可以就先打印YES,再打印出所有格子的坐标,否则打印出NO. 题解: 参考博客 如果b和w相等的时候,那么就可以用棋盘的一行来表示. 对于不相等的情况: 如果max(w,b)>min(w,b)*3+1那么这样是找出不来符合条件的连通区域的. 看图中的红色部分你会知道只有这样十十的连接起来才是最大构成情…
传送门 注意到棋盘可以看成无限大的,那么只要考虑如何构造一个尽可能合法的情况 不妨假设需要的白色格子比黑色格子少 那么容易发现最好的情况之一就是白色排一排然后中间黑的先连起来,剩下黑色的再全部填白色周围 可以证明如果需要 $w$ 个白色格子,那么黑色格子的数量不能超过 $3w+1$ 证明:首先 $w=1$ 时显然 然后考虑下一个白色格子扩展,显然从一边延伸出去,然后又多了 $3$ 个可以放黑色的位置,这样一路扩展显然可以放 $3w+1$ 个黑色的位置 然后考虑证明没有更好的方案,显然除了第一次白…
  Find the number Weak Connected Component in the directed graph. Each node in the graph contains a label and a list of its neighbors. (a connected set of a directed graph is a subgraph in which any two vertices are connected by direct edge path.) Ex…
Find the Connected Component in the Undirected Graph Find the number connected component in the undirected graph. Each node in the graph contains a label and a list of its neighbors. (a connected component (or just component) of an undirected graph i…
Description Find connected component in undirected graph. Each node in the graph contains a label and a list of its neighbors. (A connected component of an undirected graph is a subgraph in which any two vertices are connected to each other by paths,…
Description Find the number Weak Connected Component in the directed graph. Each node in the graph contains a label and a list of its neighbors. (a weak connected component of a directed graph is a maximum subgraph in which any two vertices are conne…
Strongly Connected Components A directed graph is strongly connected if there is a path between all pairs of vertices. A strongly connected component (SCC) of a directed graph is a maximal strongly connected subgraph. For example, there are 3 SCCs in…
[HDU6271]Master of Connected Component 题目大意: 给出两棵\(n(n\le10000)\)个结点的以\(1\)为根的树\(T_a,T_b\),和一个拥有\(m(m\le10000)\)个结点的图\(G\).\(T_a,T_b\)的每一个结点上都有一个信息,表示\(G\)中的一条边\((u_i,v_i)\).对于\(i\in[1,n]\),询问从\(T_a\)和\(T_b\)上分别取出链\(1\sim i\),将链上的信息所表示的边加入\(G\)中后,\(G…