ICode9

精准搜索请尝试: 精确搜索
  • LeetCode 1151 Minimum Swaps to Group All 1's Together 滑动窗口2022-09-15 04:30:10

    Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any place in the array. Solution 注意这里的交换 \(swap\) 并不是相邻两个元素的,而是任意位置的都可以。所以我们需要找到一个区间,使得所有1变换

  • 1151:素数个数2022-09-05 22:32:48

    编程求2-n中有多少个素数。 #include <iostream>using namespace std;int main(){    int n,s=0,sum=0;    cin>>n;    for(int i=2;i<=n;++i)    {        s=0;        for(int j=2;j<=i-1;++j)        {            if(i%j==0)     

  • xjtuoj 1151:把你挂在地灵殿门口当装饰品!2022-04-23 06:32:22

    题目来源 恋恋,嘿嘿,恋恋 题意看起来很无意识,实际上这个序列是由一段\(A\)类罪袋+\(BC\)混杂罪袋组合而成,因此可以先找出序列开头的一段连续上升子序列作为\(max(k-m)\)(也就是\(PosA\)) 接着考虑\(C\)类罪袋,容易看出\(C\)类罪袋必定是从\(N\)开始递减的一段子序列(倒序了),因此找到\(C

  • 1151 LCA in a Binary Tree (30 分)2022-02-06 16:35:18

     题目大意:已知一个树的前序和中序序列,求两个结点的最近公共祖先 本着试一试的做法,直接建树,然后套倍增求LCA的算法,还好数据不是很大,没卡爆数组。 #include <iostream> #include <unordered_set> #include <cstring> #include <cmath> using namespace std; const int N = 100

  • UVa 1151 Buy or Build (最小生成树)2021-07-08 18:31:55

    题目链接 先求出不买套餐的最小生成树的边 然后枚举选择哪些套餐,将套餐中的边权置为 \(0\), 和原先最小生成树的边重新进行 \(kruscal\) 而原先选不到的边,权值大于套餐和最小生成树的边,后来一定也选不到 #include<bits/stdc++.h> using namespace std; typedef long long ll; con

  • 1151 LCA in a Binary Tree(两结点的最近公共祖先)2020-03-13 21:01:17

     大致题意就是给出一棵树的先序、中序遍历序列,可以构造一棵树。然后给两个顶点,找出这两个结点的最近公共祖先。 1 #include<iostream> 2 #include<unordered_map> 3 #include<algorithm> 4 using namespace std; 5 const int maxn = 10010; 6 int m,n,pre[maxn],in[maxn],

  • POJ 1151 Atlantis2019-08-10 15:01:23

    线段树+扫描线 矩形面积并 之前写过矩形周长并   还是跟矩形周长并一样,将每一个矩形的横边和竖边处理出来 用竖边将整个平面分成若干个区间 用线段树维护这些区间被覆盖的长度 再用一条扫描线不断从下往上扫描,扫描横边 当扫描到一个矩形的下边时,将这一段区间在线段树上覆盖掉,更新

  • 1151 LCA in a Binary Tree (30 分)2019-07-19 13:40:18

      首先是鬼鬼珊的闲聊一分钟 今天给大家扯一点什么呢?好吧,最近的论文看得我想哭,最悲伤的事是看不懂呀,尤其是国外研究的论文,一个句子长到我还要进行英文的长难句解析才勉强搞得清楚其中的深刻含义,导致我每天都想躺尸。说起来还有一件事值得一提,很久之前和朋友聊天,说起恋爱这个事

  • poj_11512019-05-02 14:55:20

      Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe different regions of Atlantis. Your friend Bi

  • [Codeforces] [553Div2] [1151] 瞎讲报告2019-04-19 12:42:23

    传送链接 E. Number of Components 当时思博了。。一直在想对于\([1,r]\)的联通块和\([1,l-1]\)的联通块推到\([l,r]\)的联通块...我真的是傻了。。这题明明很水啊..换做以前肯定是可以做出来的!(flag*1) 由于是一条链,那么我们考虑就算一个联通块中的最小节点为\(i\)对答案所产生

  • poj 1151 (未完成) 扫描线 线段树 离散化2019-03-21 21:37:53

    #include<iostream>#include<vector>#include<cmath>#include<algorithm>using namespace std;#define y1 y11#define ls rt<<1,l,m#define rs rt<<1|1,m+1,rconst int maxn=1e3+10;double x1[maxn];double y1[maxn];double x2[maxn];dou

  • PAT Advanced 1151 LCA in a Binary Tree (30 )2019-03-01 17:53:41

    PAT Advanced 1151 LCA in a Binary Tree (30 )题目描述Input Specification:Output Specification:Sample Input:Sample Output:解题思路Code 题目描述 The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descend

  • Air Raid HDU 11512019-02-11 14:41:11

    题意  给定n个路口 加上一些单向路  求遍历完所有路口需要多少人  人是空降的 哪里都可以作为起点 求 最小边覆盖   (用最少的边覆盖所有的点) 也叫最小路径覆盖(更形象) 最小边覆盖==所有点-最大匹配数(匈牙利算法) 理解: 如果没有路  则要n个人  多一条路  则可以减一个人  .

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

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

ICode9版权所有