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): 441    Accepted Submission(s): 133 Problem Description A long time ago there are no himalayas between India and China, th…
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…
特别经典的一个题,还有一种方法就是二分+bfs 题意:空间内n*m个点,每个点是0或者1,0代表此点可以走,1代表不能走.接着经过q年,每年一个坐标表示此点不能走.问哪年开始图上不能出现最上边不能到达最下边的情况了 图上连通性可以使用并查集判断,但是并查集不善于删边,却善于添边.所以我们倒着来想就是离线倒序添边(横向并查,再纵向并查),当某次判断时图已经连通,就结束. 我使用二维并查集,其实就是使用结构体代替一维数组.接着就是每次一定要从x轴小的点到达x轴大的点,最后注意添边时,我们需要此点向四…
题目链接: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…
倒序操作用并查集判断是否连通,新技能get√(其实以前就会了 这题细节很多...搞得整个程序都是调试输出,几度看不下去想要重写 并查集到现在大概掌握了两个基本用途:判断是否连通 / 路径压缩(上一篇blog)UPD:判断某个区间是否被覆盖 #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #define ll long long using namespace st…
题目链接 给一个图, 由01组成, 1不能走. 给q个操作, 每个操作将一个点变为1, 问至少多少个操作之后, 图的上方和下方不联通. 二分操作, 然后bfs判联通就好了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <complex> #include <cmat…