HDU 5652 India and China Origins】的更多相关文章

India and China Origins 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5652 Description A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in sync at that time, but eventually hima…
India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 676    Accepted Submission(s): 227 Problem Description A long time ago there are no himalayas between India and China, the…
India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in…
India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 441    Accepted Submission(s): 133 Problem Description A long time ago there are no himalayas between India and China, th…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5652 题目大意:n*m的矩阵上,0为平原,1为山.q个询问,第i个询问给定坐标xi,yi,表示i年后这里的平原上会长出山.问第几年以后印度和中国交流会被阻碍 思路:(官方题解)这是一个连通性的问题.你会发现如果将所有操作逆序来看的话就很容易用并查集来处理了. 首先把所有的山峰都加到图中,然后逆序处理每个操作: 对某次操作,在图中删除该位置的山峰,然后判断两个点是否联通,一旦联通就得到了结果. 这里需…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5652 Problem Description A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in sync at that time, but eventually himalayas rise…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5652 题意:一张n*m个格子的点,0表示可走,1表示堵塞.每个节点都是四方向走.开始输入初始状态方格,之后输入Q个操作,表示第(x,y)个格子由0变为1:问你在第几次时不能由最下的一行到最上面的一行.中国在最上面一行的上面,印度在最下面一行的下面:如果最终还是连通的,输出-1: 思路:直接离线逆序处理,用并查集维护: #include<bits/stdc++.h> using namespace…
特别经典的一个题,还有一种方法就是二分+bfs 题意:空间内n*m个点,每个点是0或者1,0代表此点可以走,1代表不能走.接着经过q年,每年一个坐标表示此点不能走.问哪年开始图上不能出现最上边不能到达最下边的情况了 图上连通性可以使用并查集判断,但是并查集不善于删边,却善于添边.所以我们倒着来想就是离线倒序添边(横向并查,再纵向并查),当某次判断时图已经连通,就结束. 我使用二维并查集,其实就是使用结构体代替一维数组.接着就是每次一定要从x轴小的点到达x轴大的点,最后注意添边时,我们需要此点向四…
题目链接 给一个图, 由01组成, 1不能走. 给q个操作, 每个操作将一个点变为1, 问至少多少个操作之后, 图的上方和下方不联通. 二分操作, 然后bfs判联通就好了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <complex> #include <cmat…
题目大意:给你一个地图0代表可以通过1代表不可以通过.只要能从第一行走到最后一行,那么中国与印度是可以联通的.现在给你q个点,每年风沙会按顺序侵蚀这个点,使改点不可通过.问几年后中国与印度不连通.若一直联通输出-1. 题目思路:看数据这道题就是卡时间的,我们的基本思路是每当风沙侵蚀一个点,我们就进行一次广搜,看看图上下是否联通,我们应尽可能的去优化这个过程. 所以我们可以在遍历年的时候用二分查找: 若当年图可以上下联通,则继续向右查找 若当年图上下无法联通,则向左查找 剪枝: 为了省时间我们应该…