ICode9

精准搜索请尝试: 精确搜索
  • C#控件随窗体大小变化2022-08-08 12:32:03

    非自创,转载自大神易大胆888 private float X; private float Y; private void setTag(Control cons) { foreach (Control con in cons.Controls) { con.Tag = con.Width +":" + con.Height + ":" + con.Left + &q

  • winfrom窗体控件自适变化2022-07-06 10:33:55

    直接上代码 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 11

  • LeetCode剑指 Offer 13. 机器人的运动范围(DFS + 回溯)2022-03-21 17:34:12

    力扣   解题思路: 开辟一个相同规格的二维数组 book, 将不符合条件的位置设置为 1 ,再利用DFS深度优先搜索 ,找出能到达的最大格子。 class Solution { public: int dir[4][2] = {1 , 0 , -1 , 0 , 0 , 1 , 0 , -1}; void DFS(vector<vector<int>>& book ,int row ,int

  • 【Algorithm】广度优先搜索(BFS)2022-03-19 21:02:35

    前面介绍了深度优先搜索,可知 DFS 是以深度作为第一关键词的,即当碰到岔道口时总是先选择其中的一条岔路前进,而不管其他岔路,直到碰到死胡同时才返回岔道口并选择其他岔道口。 接下来介绍的广度优先搜索则是以广度为第一关键词,当碰到岔路口时,总是先依次访问从该岔路口能直接到达的

  • LeetCode 1765. 地图中的最高点2022-02-06 20:34:39

    1765. 地图中的最高点 Solution 思路:开始的思路是直接把水域固定,然后扩散,但是扩散的方式不对,我是默认一圈的最小值直接加1,但是会出现问题,正确做法多源BFS,就是全部默认为-1,然后从水域开始做BFS,如果遇到不是-1的格子,说明一定是从之前的水域出发了,所以不能重复更新,不然就不满足要求了

  • 第24题:一马当先2022-02-03 15:58:52

    题目描述: 下过象棋的人都知道,马只能走’日’字形(包括旋转90°的日),现在想象一下,给你一个n行m列网格棋盘, 棋盘的左下角有一匹马,请你计算至少需要几步可以将它移动到棋盘的右上角,若无法走到,则输出-1. 如n=1,m=2,则至少需要1步;若n=1,m=3,则输出-1。 示例: 输入: n = 1 m = 2 输出: 1

  • 542. 01 矩阵2021-12-21 13:30:01

    给定一个由 0 和 1 组成的矩阵 mat ,请输出一个大小相同的矩阵,其中每一个格子是 mat 中对应位置元素到最近的 0 的距离。 两个相邻元素间的距离为 1 。 输入:mat = [[0,0,0],[0,1,0],[0,0,0]] 输出:[[0,0,0],[0,1,0],[0,0,0]]   输入:mat = [[0,0,0],[0,1,0],[1,1,1]] 输出:[[

  • 深度优先搜索模板2021-08-23 08:01:36

    深度优先搜索模板 简介 深度优先搜索是一种遍历所有数据的方法,可以用在最短路径上 模板 岛屿的个数的BFS的方法 private void BFS(boolean[][] grid, boolean[][] visited, Point p) { Queue<Point> queue = new LinkedList<>(); queue.offer(p); // 加入初始

  • winform使用Resize设置窗口控件大小按照窗口大小等比例缩放2021-08-12 10:32:54

    直接贴代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Winform2 { public

  • (2021-5)搜索类题目(bfs dfs)-计算水洼数量 c++2021-05-10 20:00:30

    题目描述 题目:有一块N*M的土地,下雨后积起了雨水,有水的区域标记为"w",干燥标记为".",8连通区域被认为是连接在一起的;请求出院子里有多少水洼? input w w w . . . . . . . w w w w . . output 2 思路: 对于8连通区域在搜索时,搜索时设置8个方向;对'w'进行一次搜索;搜索完毕后被搜

  • C#放大窗体控件也随之改变2021-05-08 21:31:56

    private float x;//定义当前窗体的宽度 private float y;//定义当前窗体的高度 public SalesStatistics() { InitializeComponent(); x = this.Width; y = this.Height; setTag(this); }

  • Leetcode 59. 螺旋矩阵 II2021-04-04 18:33:57

    地址 https://leetcode-cn.com/problems/spiral-matrix-ii/ 给你一个正整数 n ,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix 。 示例 1: 输入:n = 3 输出:[[1,2,3],[8,9,4],[7,6,5]] 示例 2: 输入:n = 1 输出:[[1]] 解法 使用 int addx[4]

  • 二解NOIP普及组2017年T3棋盘2021-01-04 11:59:58

    题目描述:https://www.acwing.com/problem/content/473/ 题目具体内容:   有一个m×m的棋盘,棋盘上每一个格子可能是红色、黄色或没有任何颜色的。你现在要从棋盘的最左上角走到棋盘的最右下角。 任何一个时刻,你所站在的位置必须是有颜色的(不能是无色的),你只能向上、下、左、

  • 1162. As Far from Land as Possible2020-11-27 22:04:21

    package LeetCode_1162 import java.util.* /** * 1162. As Far from Land as Possible * https://leetcode.com/problems/as-far-from-land-as-possible/ * Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, * f

  • C#窗体内控件大小随窗体等比例变化 (转)2020-08-12 08:33:45

    一、首先定义全局变量 1 private float X;//当前窗体的宽度 2 private float Y;//当前窗体的高度 3 private bool IsFirst = true; 二、定义一下两个函数 1 /// <summary> 2 /// 将控件的宽,高,左边距,顶边距和字体大小暂存到tag属性中 3 /// </summary> 4 /// <param name="

  • uva 10196 将军 模拟2020-07-14 15:28:53

                代码  // 11235.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include <vector> #include <string> using namespace std; /* ..k..... ppp.pppp ........ .R...B.. ........ ........ PPPPPPPP K....... rnb

  • acwing 189. 乳草的入侵 bfs2020-06-24 22:53:30

    地址 https://www.acwing.com/solution/content/15240/ 农民约翰一直努力让他的草地充满鲜美多汁而又健康的牧草。 可惜天不从人愿,他在植物大战人类中败下阵来。 邪恶的乳草已经在他的农场的西北部份占领了一片立足之地。 草地像往常一样,被分割成一个高度为Y, 宽度为X的直角

  • DFS-深度优先搜索2020-02-05 20:42:35

    模板题 ①迷宫寻路 #include <iostream> #include<bits/stdc++.h> using namespace std; int n,m; string a[1001]; int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};//定义上下左右四个方向 int beginx,beginy,endx,endy; int newx,newy; void begin()//搜索起点 * { for(i

  • [LC] 490. The Maze2019-12-06 12:01:32

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the ball�

  • leetcode 463. Island Perimeter2019-09-19 17:55:14

    You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i

  • 洛谷P1443 马的遍历2019-04-12 22:55:00

    https://www.luogu.org/problemnew/show/P1443 很经典的搜索题了,蒟蒻用广搜打的 不说了,上代码! #include<bits/stdc++.h>using namespace std;struct xy {//定义结构体 int x,y;//x,y两个方向} node,Top;int dx[8]={2,-2,2,-2,-1,1,-1,1};int dy[8]={1,1,-1,-1,2,2,-2,-2};//马

  • 递归和回溯_leetcode-floodfill2019-03-19 10:52:58

    class Solution(object): def numIslands(self, grid): """ :type grid: List[List[str]] :rtype: int """ self.res = 0 if not grid : return self.res self.drection = [[-

  • LeetCode 864. Shortest Path to Get All Keys2019-02-24 16:55:58

    864. Shortest Path to Get All Keys We are given a 2-dimensional grid. “.” is an empty cell, “#” is a wall, “@” is the starting point, (“a”, “b”, …) are keys, and (“A”, “B”, …) are locks. We start at the starting point, and one move consists

  • 牛客寒假算法基础集训营5 I 炫酷镜子2019-02-02 11:53:19

    链接:https://ac.nowcoder.com/acm/contest/331/I来源:牛客网小希拿到了一个镜子块,镜子块可以视为一个N x M的方格图,里面每个格子仅可能安装`\`或者`/`的镜子,会反射90°光线,也可能没有安装镜子,使用`.`代替。 但她看不清楚里面的镜子构造是怎样的。 你是这块镜子块的主人,所以你想计

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有