ICode9

精准搜索请尝试: 精确搜索
  • 数据结构-排序(五)快速排序2022-02-28 11:05:28

    本文详细介绍了快速排序的算法思想、代码实现和算法效率分析,还包括示例和可视化动图,易理解! Let’s go!

  • C. Game Master(强连通分量,缩点,建图2022-02-27 17:33:51

    C. Game Master 题意: n n n 个选手在进行比赛,比赛有两个场地,每个选手都有两个值表示在这两个场地上的能力值 n −

  • 归并排序——自顶向下改进2022-02-27 15:15:42

    import java.util.Arrays; /** * @Auther: dzy * @Date: 2022/2/27 14:50 * @Description: 归并排序加强 * 1、通过在调用归并函数前判断a[mid]和a[mid+1]的大小决定是否需要归并,这样减少了一定的比较时间 * 2、通过每次调用sort排序函数,每次递归原数组和辅助数组轮换,轮

  • C++ quick sort2022-02-27 14:33:21

    int Util::partition9(int *arr, int low, int high) { int pivot = *(arr + high); int i = low - 1; for (int j = low; j < high; j++) { if (arr[j] < pivot) { i++; swap(&arr[i],&arr[j]);

  • 每日一题 02242022-02-24 21:31:37

    (2022.02.24)每日一题 修剪二叉搜索树 今天上班第一天,好累! 今天都没力气思考题目。。。。 先把题解写上,大致思路差不多,但是还是没写出来。。。 class Solution { public: TreeNode* trimBST(TreeNode* root, int low, int high) { if(root == nullptr) return nullptr;

  • Leetcode945. 使数组唯一的最小增量2022-02-24 20:02:25

    Every day a leetcode 题目来源:945. 使数组唯一的最小增量 解法1:hash计数 用一个hash表统计nums中各数字出现的次数。 设置count统计+1的次数。 遍历hash表,若hash[i]>1,说明有重复个数字,根据贪心的思想,应该将hash[i]-1个该值+1,则有: count+=hash[i]-1; hash[i+1]+=hash[i]-1; h

  • 669. 修剪二叉搜索树2022-02-24 13:35:55

    深度优先搜索 class Solution { public TreeNode trimBST(TreeNode root, int low, int high) { if (root == null){ return root; } /** * 如果根节点小于最小值,那其左子树肯定也小于最小值,那就只用判断右子树 * 同

  • 2022.2.21蓝桥杯准备训练2022-02-21 23:31:23

    时隔多年,再次入坑算法竞赛。。。。。 今天复习了点双,边双,割边缩点,割点缩点,强联通分量。 在强联通分量板题中,注意tarjan中的写法 if(!dfn[t]){ tarjan(t); low[x] = min(low[x],low[t]); }else if(ins[t]){ low[x] = min(low[x],dfn[t]);

  • [NOI2017] 游戏2022-02-21 21:02:33

    题意: 思路:其实很水就二进制枚举一下x是'A'还是'a'即可 不过做题的时候我u->v(选u就会选v)我没有连v'->u,理论上图是含盖必要逻辑的,但是我们要的是含盖所有逻辑,因为要保持2-SAT图的对称性,这是很多问题的前提。 code: #include<bits/stdc++.h> using namespace std; const int N=1

  • 兵贵神速——快速排序2022-02-21 18:00:55

    C++源码: //program 3-3 #include<conio.h> #include <iostream> using namespace std; int Partition(int r[],int low,int high)//划分函数 { int i=low,j=high,pivot=r[low];//基准元素 while(i<j) { while(i<j&&r[j]>pivot) j--;/

  • C操作符default的使用2022-02-20 20:58:56

    default可返回值的默认值。 1、值类型时,返回值; double x = default(double);//值类型,返回值0。 2、引用类型时,返回null; Form myForm = default(Form);//引用类型,返回null 3、枚举类型时,返回0(要注意出错)。没有0时,同样返回0。为了避免别人使用出错,定义枚举时,最好定义0的值 st

  • 题解 nkoj9162 改色找根2022-02-20 11:31:32

    \(1\le n,m\le 2\times 10^5\)。 考虑一个简单直接的建图,若将 \(a\) 颜色作为树根需要将 \(b\) 颜色变为 \(a\),从 \(a\) 向 \(b\) 连边。 枚举每个颜色 \(a\) 的所有点,用类似虚树的方法找出所有 \(a\) 颜色依赖的颜色并连边。连边可以用倍增优化建图。倍增优化建图和倍增是一样的

  • tarjan22022-02-15 20:31:28

    反过来调过去,我还是感觉没学明白缩点 讲一个有向图中的所有强连通分量缩成一个点后,构成的新图是一个DAG。 一个点所在的强连通分量一定被该点所在DFS搜索树所包含 树上的边大致分为:树枝边,前向边(从上往下指),后向边(从下往上指),横叉变。其中前向边肉眼可见地没什么卵用 接下来开始算

  • 【HZOJ/Tarjan】#E.采集糖果2022-02-15 15:01:01

    E. Trick or Treat on the Farm 采集糖果 题目描述 每年万圣节,威斯康星的奶牛们都要打扮一番,出门在农场的N(1≤N≤100000)个牛棚里转悠,来采集糖果.她们每走到一个未曾经过的牛棚,就会采集这个棚里的1颗糖果. 农场不大,所以约翰要想尽法子让奶牛们得到快乐.他给每一个牛棚设置了

  • 【HZOJ/Tarjan】#B.受欢迎的牛2022-02-15 08:31:11

    题目描述 每一头牛的愿望就是变成一头最受欢迎的牛。现在有N头牛,给你M对整数(A,B),表示牛A认为牛B受欢迎。 这 种关系是具有传递性的,如果A认为B受欢迎,B认为C受欢迎,那么牛A也认为牛C受欢迎。你的任务是求出有多少头 牛被所有的牛认为是受欢迎的。 输入格式 第一行两个数

  • 【模板】tarjan(一般)2022-02-15 07:31:25

    #include<stdio.h> #include<stack> namespace bikuhiku{ template <typename _T> _T gtr(_T &_compare_x,_T &_compare_y) { return _compare_x > _compare_y ? _compare_x : _compare_y; } template <typename _T>

  • 【HZOJ/Tarjan】#A.信息传递2022-02-14 19:00:17

    #include<stdio.h> #include<stack> namespace bikuhiku{ template <typename _T> _T gtr(_T &_compare_x,_T &_compare_y) { return _compare_x > _compare_y ? _compare_x : _compare_y; } template <typename _T> _T les(_T &

  • 别再写 main 方法测试了,太 Low,这才是专业 Java 测试方法。。2022-02-11 09:35:55

    来源:https://juejin.cn/post/6844903936869007368 前言 "If you cannot measure it, you cannot improve it". 在日常开发中,我们对一些代码的调用或者工具的使用会存在多种选择方式,在不确定他们性能的时候,我们首先想要做的就是去测量它。大多数时候,我们会简单的采用多次计数的方

  • 交换类排序2022-02-11 01:34:17

    一、冒泡排序(Bubble Sort) 1.时间复杂度:O(n2) 2.空间复杂度:O(1) 1 void BubbleSort(int* a, int num) { 2 int i, j; 3 for (i = 1; i <= num - 1; ++i) { 4 for (j = 1; j <= num - i; ++j) { 5 if (a[j] > a[j + 1]) {//前后交换 6

  • arXiv journal 2022.02102022-02-10 15:05:42

    Longitudinal structure function FL at low Q2 and low x with model for higher twist: an update https://arxiv.org/pdf/2202.04223.pdf abstract: A reanalysis of the model for the longitudinal structure function FL(x, Q2) at low x and low Q2 was undertaken, i

  • P3731 [HAOI2017]新型城市化2022-02-10 08:33:29

    给你一张图,保证原图补图是个二分图,在原图中加入一条边能使原图最大团数至少加一的边有哪些? 最大团数指使得选中的点集两两有边的最大点数。 点数 \(\leq 10^4\),\(0\leq\) 边数 \(\leq \min(1.5\times 10^5,\frac{n(n-1)}{2})\)。 无重边,无自环。 sol 由于补图的性质比较优秀,考虑处

  • android studio 报错 External file changes sync may be slow: The current inotify(7) watch limit is too2022-02-09 22:34:12

    在/etc/sysctl.d文件夹下新建60-jetbrains.conf文件 sudo touch /etc/sysctl.d/60-jetbrains.conf 编辑文件 写入 # Set inotify watch limit high enough for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm).# Create this file as /etc/sysctl.d/60-jetbrains.conf (De

  • 【UVM基础】uvm_info 宏介绍2022-02-09 18:58:19

    `uvm_info("my_driver", "data is drived", UVM_LOW) uvm_info宏的功能与Verilog中display语句的功能类似,但是它比display语句更加强大。 它有三个参数: 第一个参数是字符串, 用于把打印的信息归类;第二个参数也是字符串, 是具体需要打印的信息;第三个参数则是冗余级别。 在验证

  • 力扣-面试题10.05 稀疏数组搜索(C++)- 二分变形2022-02-08 18:31:13

    题目链接:https://leetcode-cn.com/problems/sparse-array-search-lcci/ 题目如下: class Solution { public: int findString(vector<string>& words, string s) { int low=0,high=words.size()-1; while(low<=high){ int mid=low+(hi

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

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

ICode9版权所有