ICode9

精准搜索请尝试: 精确搜索
  • 7.6 圆方树2022-07-06 16:32:27

    \(\large \text{Date: 7.6}\) 圆方树 \(\rm Notes\) 众所周知,在无向图中,存在若干的点双联通图。 点双联通图:图中任意两不同点之间都有至少两条点不重复的路径。 我们称这张图中所有原来的点叫“圆点”。接着,对于每一个原图中的点双联通子图,我们新开一个点,删去子图中原来的边,将这个

  • 存题(搜索)2022-07-06 14:33:11

    1. aoj 0033:https://onlinejudge.u-aizu.ac.jp/problems/0033 1 #include<bits/stdc++.h>//AOJ 0033 2 using namespace std; 3 int ball[11]; 4 bool flag; 5 void Dfs(int cnt,int left,int right) 6 { 7 if(flag) return; 8 if(cnt==10) 9 {

  • CF335F Buy One, Get One Free 题解--zhengjun2022-07-04 20:05:21

    思路 一道很妙的反悔贪心题。 考场上打的是 \(O(n\times k)\) 的 \(dp\),其中 \(k\) 是 \(a_i\) 的种类数。 考虑贪心,先从大到小枚举 \(a_i\),把相同的 \(a_i\) 一起处理。 当前可以白嫖的直接白嫖,如果不能再白嫖了,再看看如果前面白嫖了一个 \(x\),当前的为 \(y\)。 若 \(x<y\),显然是

  • 【FPGA学习笔记】VL32 非整数倍数据位宽转换24to1282022-07-04 13:31:44

    描述 实现数据位宽转换电路,实现24bit数据输入转换为128bit数据输出。其中,先到的数据应置于输出的高bit位。 电路的接口如下图所示。valid_in用来指示数据输入data_in的有效性,valid_out用来指示数据输出data_out的有效性;clk是时钟信号;rst_n是异步复位信号。         输入描述

  • 最短路常用算法2022-07-03 19:04:50

    弗洛伊德(Floyd-Warshall) 时间复杂度\(O(n^3)\) 多元最短路,核心思想是依次将所有点作为中转点并更新所有路径。 核心代码也只有5行 for(int i=1;i<=n;++i)//外层循环一定是中转点 for(int j=1;j<=n;++j) for(int k=1;k<=n;++k) if(g[j][k]>g[j][i]+g[i][k])

  • LeetCode673 最长递增子序列的个数2022-07-03 16:01:04

    LeetCode673 最长递增子序列的个数 贪心 + 前缀和 + 二分查找 \(q[i][]\) 数组表示所有能成为长度为 \(i\) 的最长上升子序列的末尾元素的值 \(cnt[i][j]\) 记录以 \(q[i][j]\) 为结尾的最长上升子序列的个数 参考 class Solution: def findNumberOfLIS(self, nums: List[int]

  • 1487:【例 2】北极通讯网络 - 题解2022-07-03 14:31:50

    1487:【例 2】北极通讯网络 - 题解 原题地址:点击这里 只需要找到最小生成树中第 k 大的边即可。 1 #include<cstdio> 2 #include<cmath> 3 #include<algorithm> 4 5 #define N 505 6 #define M N*N*2 7 #define K 105 8 9 using namespace std; 10 11 int n,m,k; 12

  • 719. 找出第 K 小的数对距离2022-07-02 15:35:39

    719. 找出第 K 小的数对距离 数对 (a,b) 由整数 a 和 b 组成,其数对距离定义为 a 和 b 的绝对差值。 给你一个整数数组 nums 和一个整数 k ,数对由 nums[i] 和 nums[j] 组成且满足 0 <= i < j < nums.length 。返回 所有数对距离中 第 k 小的数对距离。 示例 1: 输入:nums = [1,3,1],

  • 力扣 题目79- 单词搜索2022-07-02 15:32:37

    题目 题解 回溯算法 找到开头然后对上下左右四个方向 回溯 已经遍历过的至* 直到长度与word一致 代码 1 #include<iostream> 2 #include<vector> 3 #include<unordered_map> 4 using namespace std; 5 //1是上 2是下 3是左 4是右 6 bool loop(vector<vector<char>>& boar

  • HYSBZ1036 [ZJOI2008]树的统计(树链剖分)2022-07-01 19:32:47

    将树通过树链剖分转化成线性序列,用线段树维护最值,和值即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 const int maxn=30005; 7 int n,m; 8 int head[maxn],to[maxn<<1],nxt[maxn

  • codeforces 1648B2022-06-30 14:01:08

    B. Integral Array 思路: 枚举因子,\([x/y]=z,则y*z<=x<=y*z+y-1\) 代码: #include <bits/stdc++.h> #define int long long int _ = 0, Case = 1; using namespace std; #define all(v) begin(v),end(v) #define nline '\n' const int N = 1000010; int cn

  • 力扣 题目76- 最小覆盖子串2022-06-29 17:03:31

    题目 题解 直接看代码吧  代码 1 #include<iostream> 2 #include<string> 3 #include<unordered_map> 4 using namespace std; 5 class Solution { 6 public: 7 string minWindow(string s, string t) { 8 unordered_map<char, int> hs, h

  • NC24017 [USACO 2016 Jan S]Angry Cows2022-06-28 23:32:24

    NC24017 [USACO 2016 Jan S]Angry Cows 题目 题目描述 Bessie the cow has designed what she thinks will be the next big hit video game: "Angry Cows". The premise, which she believes is completely original, is that the player shoots cows with a slingshot i

  • NC14301 K-th Number2022-06-28 19:03:29

    NC14301 K-th Number 题目 题目描述 Alice are given an array A[1..N] with N numbers. Now Alice want to build an array B by a parameter K as following rules: Initially, the array B is empty. Consider each interval in array A. If the length of this interval is le

  • NC24083 [USACO 2017 Dec P]Greedy Gift Takers2022-06-28 17:34:24

    NC24083 [USACO 2017 Dec P]Greedy Gift Takers 题目 题目描述 Farmer John's nemesis, Farmer Nhoj, has N cows (\(1≤N≤10^5\)), conveniently numbered 1…N. They have unexpectedly turned up at Farmer John's farm, so the unfailingly polite Farmer John is att

  • AcWing 11. 背包问题求方案数2022-06-28 17:07:10

    有两种做法 第一种定义cnt[j]为体积恰好为j的所有方案数 第二种定义cnt[j]为体积不超过j的所有方案数 定义不同,初始状态(边界)不同,计算答案的方式也不同 恰好的写法 //不超过的写法 #include<bits/stdc++.h> using namespace std; #define fr first #define se second typedef p

  • 洛谷 P6278 [USACO20OPEN]Haircut G2022-06-27 23:05:19

    Description 有长为 $ n$ 的序列 \(a[1...n]\) 按 \(j = (0, 1, 2, ... , n - 1)\) 依次输出把大于 \(j\) 的 \(a[i]\) 改为 \(j\) 后逆序对的个数。 Constraints \(1 \le n \le 10^6\), \(0 \le \forall a[i] \le n\)。 Solution 平常的逆序对可以直接用树状数组维护,但是这题有多

  • P31492022-06-27 13:04:00

    P3179 排序 给定有 \(n\) 个数的序列,\(m\) 次操作。 每次操作选择位置 \(k\) 上的数,将序列中小于等于 \(k\) 的数排序后放回。 求每次操作后序列的逆序对个数。 不进行操作的答案就是初始序列逆序对数。 可以发现,对于某个选择位置 \(k\) 的操作,只会影响到序列中只由小于等于选

  • 2022-6-272022-06-27 10:03:05

    如何回形遍历一个矩阵: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #include <string.h> 5 int m,n; 6 int main() 7 { 8 scanf("%d%d",&m,&n); 9 int a[m][n],visit[m][n]; 10 memset(visi

  • AtCoder Beginner Contest 2562022-06-25 13:31:59

    A - 2^N 签到 #include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << ( 1 << n ) << endl; } B - Batters 按照要求模拟一下 n = int(input()) a = list(map(int, input().split())) now = [ 0 , 0 , 0, 0

  • 洛谷P2602 [ZJOI2010] 数字计数 (数位DP)2022-06-25 12:03:05

    白嫖的一道省选题...... 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 typedef long long LL; 6 int dig[15],pos; 7 LL dp[15][10][15],ans[2][10]; 8 9 LL dfs(int pos,int val,int cnt,bool lead,bool li

  • Keshi in Search of AmShZ (最短路好题->dij优化dp)2022-06-24 12:02:12

    首先先把题目搞明白, 两个指令, 1.随机走向一个城市 2.删除一条边 使从1出发到n的天数最短。 一开始的思路是二分,然后暴力删边,跑最长路判断。明显时间复杂度太高了。 既然他是一步一步走的,那么就一步一步分析,不如说一层一层分析 dp方程为dis[i]为从1到i的最小距离,cnt[i]为i的入度 j

  • CF1695D2. Tree Queries (Hard Version) (树形DP, 思维)2022-06-21 22:34:03

    https://codeforces.com/contest/1695/problem/D2 题意: 思路: 找任意度数大于3的点u做根,u有c个子树,则c-1个子树都需要有询问点 这是因为,度数大于3的点至少有两棵子树有询问点,这样对于一个子树,子树外有询问点,只需关注子树内 树上问题以一个子树为一个阶段进行分析 #include<bits/

  • 2022暑假集训队选拔赛补题2022-06-21 21:33:46

    E ginger的染色 首先对于一个排列 ,如果看成环图的结构,那么 就向 连一条无向边。所以对于任意一个排列就会产生若干个环,连通性可以用并查集维护,现在对每个点进行黑白染色,题意转换为对于环中任意相邻两点颜色不能相同,那么只有偶数元环才能够染色成二分图,而每个偶环的方案数为 ,设当前

  • 初始数组以及创建数组2022-06-21 13:34:07

    初始数组 数组用来储存元素,使用循环遍历和判断将数组內满足条件的值进行输出。 int x; int[] numbers = new int[100]; double sum = 0; int cnt = 0; x = sc.nextInt(); while (x != -1){ numbers[cnt] = x; sum+=x; cnt++; x=sc.nextInt(); } if (cnt>0){

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

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

ICode9版权所有