实測POJ应该是採取一个一个点測.哪个点fail了就输出哪个点的状态,但接下来的点貌似还是要測. 測试方法,1000先測出有6个測点1,2,3,4,6.15,然后交了下面代码. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int q[65540]; unsigned short r,h; int main() { int i,j,k,g; int a,b,c…
BFS算法与树的层次遍历很像,具有明显的层次性,一般都是使用队列来实现的!!! 常用步骤: 1.设置访问标记int visited[N],要覆盖所有的可能访问数据个数,这里设置成int而不是bool,基于一个考虑,多次循环时不用每次都清空visited,传递进去每次一个数字即可,比如第一次标记为1,判断也采用==1,之后递加即可. 2.设置一个node,用来记录相关参数和当前的步数,比如: struct node { int i; int j; int k; int s;//步数 }; 3.设计…
题目链接:http://poj.org/problem?id=1651 Description The multiplication puzzle is played with a row of cards, each containing a single positive integer. During the move player takes one card out of the row and scores the number of points equal to the prod…