25_03_27 & 蓝桥杯题单分类:搜索与查找

?6...

BFS()不会遍历全部可达路径,BFS()只会找到最短路径最优解
没想到按照字典序建立方向就可以让路径按字典序进行排序
但是存储路径确实用了比较特殊的方法:typedef struct{x,y,path})node;

把你挂墙上去
  while (!que.empty())
  {
    int size = que.size();

    for (int j = 0; j < size; j++)
    {
      pair<int, int> cur = que.front();
      que.pop();

      visited[cur.first][cur.second] = true;
      for (int i = 0; i < 4; i++)
      {
        int nx = cur.first + dir[i][0];
        int ny = cur.second + dir[i][1];


做数学除法题变量名要用double类型

耻辱墙
bool check(){
  int a = nums[0];
  int b = nums[1];
  int c = nums[2];

  int d = nums[3];
  int e = nums[4];
  int f = nums[5];
  int g = nums[6];
  int h = nums[7];
  int i =  nums[8];

  return (a + b/c + (f + 10 *e + 100 * d)/(i + 10 * h + 100 * g)) == 10;
}


posted @ 2025-03-27 17:54  Tongkuly  阅读(32)  评论(0)    收藏  举报