A move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y). Given a starting point (sx, sy) and a target point (tx, ty), return True if and only if a sequence of moves exists to transform the point (sx, sy) to (tx,
题目链接:http://codeforces.com/contest/1131/problem/F 题目大意 给定n个操作,其意义是把两个线段区间合并成一个, 现在要构造一种排列使得这些操作合法。 题目分析 我们可以用并查集来表示一个已经归为一种类型的区间, 那么对于下一种操作x,y我们可以用vector数组来模拟合并
DFS深度搜索;之前一直和bfs的用法搞不太清楚;写了题才能慢慢参透吧,看了别的博客的代码,感觉能更好理解dfs在图中的应用; 这个题目的意思是一个人去救另一个人,找出最短的寻找路径; #include<stdio.h>int n,m,p,q,min=99999999;int a[51][51],book[51][51];void dfs(int x,int y,
通过对VC版本的auto_ptr的源代码得知VC版本还有一点小缺陷,又对VS版本的auto_ptr做了一些剖析,具体代码和注释如下: 1 //假设全局pa2都是用pa1来构造 2 //如:pa2(pa1)、pa2=pa1 3 4 template<class _Ty> //auto_ptr类声明 5 class auto_ptr; 6 7 template<class _T
一起来看流星雨吧(话说我还没看到过流星雨呢) Problem 小A则听说另一个骇人听闻的消息: 一场流星雨即将袭击整个霸中,由于流星体积过大,它们无法在撞击到地面前燃烧殆尽,届时将会对它撞到的一切东西造成毁灭性的打击。 很自然地,小A开始担心自己的安全问题。他一定要在被流星砸到前,到达一
Find a way HDU - 2612 Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the countryside, but Merceki’s home is
链接:https://ac.nowcoder.com/acm/contest/332/J 题意: 你在一个 n 行 m 列的网格迷宫中,迷宫的每一格要么为空,要么有一个障碍。 你当前在第 r 行第 c 列(保证该格子为空)。每次移动你可以向上下左右任意一个方向移动一格,前提是不能走到障碍上,也不能超出迷宫的边界。 你向左移动的次