<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[shejunda的博客]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/shejunda</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; shejunda]]></copyright><item><title><![CDATA[初识决策树]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/122723017</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/122723017</guid><author>shejunda</author><pubDate>Thu, 27 Jan 2022 21:04:28 +0800</pubDate><description><![CDATA[决策树的生成主要分以下两步，这两步通常通过学习已经知道分类结果的样本来实现。

1. 节点的分裂：一般当一个节点所代表的属性无法给出判断时，则选择将这一节点分成2个

子节点（如不是二叉树的情况会分成n个子节点）

2. 阈值的确定：选择适当的阈值使得分类错误率最小 （Training Error）。



比较常用的决策树有ID3，C4.5和CART（Classification And Regression Tree），CART的分类效果一般优于其他决策树。



ID3: 由增熵（Entropy）原理]]></description><category></category></item><item><title><![CDATA[Educational Codeforces Round 109 (Rated for Div. 2)]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/117048687</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/117048687</guid><author>shejunda</author><pubDate>Wed, 19 May 2021 22:46:24 +0800</pubDate><description><![CDATA[E. Assimilation IV
1）将矩阵保存为a[i][j]
2）对于每一列，考虑它对答案的贡献
依题意，对于n！种排列中的一种p，对于第j列，
如果有一行i，使得p[i]&gt;=a[i][j]，那么这一列对答案贡献1
3）可以反过来考虑什么情况下第j列不贡献，那就是每一个i都有p[i]&lt;a[i][j]
4）方案计数：
对于第j列，枚举i
表示当前对1~i-1进行排列，sum表示前面已经排列了sum个，
tmp为当前的计数,cnt[i]表示当前列a值为i的行的个数
那么更新tmp：tmp=C]]></description><category></category></item><item><title><![CDATA[Codeforces Round #715 (Div. 1) D. Swap Pass]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/116140184</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/116140184</guid><author>shejunda</author><pubDate>Sun, 25 Apr 2021 23:30:55 +0800</pubDate><description><![CDATA[D. Swap Pass
题意：每次选择平面上的两个点i，j，然后swap（a[i],a[j])，并在两点间连线，构造一种方案使得最后所有连线不相交（可以在节点处相交），并且a[i]=i
题解:
(1)先忽略a[i]=i的点
其余点可以分成下图若干个环

(2)考虑交换环上任意两点,如下图,
可以看到交换后的效果是把两个环合并成一个

(3那么我们就可以选择一个点为中心点,然后做一个极角排序,

...]]></description><category></category></item><item><title><![CDATA[cf #696 div2]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/113643836</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/113643836</guid><author>shejunda</author><pubDate>Thu, 04 Feb 2021 14:34:42 +0800</pubDate><description><![CDATA[C. Array Destruction
题意：
给一个长度为2n的数列，每次可选择和为x的两个数删掉，然后x变为删掉的两个数中较大的数。初始的x可自由设置。
问是否能把数列删完
题解：
首先要删完数列，最大的数肯定是最先删掉。
看到n比较小，可以暴力枚举和最大的数一起删掉的数。
然后模拟就好了。
#include&lt;bits/stdc++.h&gt;
using namespace std;

const int maxn=1e6+5;
int cnt[maxn],a[2005];

int main]]></description><category></category></item><item><title><![CDATA[D. Divide and Summarize（codeforces #689 div2)]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/111241543</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/111241543</guid><author>shejunda</author><pubDate>Tue, 15 Dec 2020 21:55:35 +0800</pubDate><description><![CDATA[题意：每次操作可以取数列的最大最小值的平均值，把数列分成大于和小于的两段（不改变原顺序），得到的数列的和是我们能得到的和，询问哪些数可以得到

题解：二分


#include&lt;bits/stdc++.h&gt;
using namespace std;

#define ll long long
const int maxn=1e5+5,inf=0x7fffffff;
int lcnt,rcnt,n;
int st1[maxn],st2[maxn],a[maxn];
map&lt;ll,int&gt]]></description><category></category></item><item><title><![CDATA[E. Water Level(codeforces #689 div2 )]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/111241108</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/111241108</guid><author>shejunda</author><pubDate>Tue, 15 Dec 2020 21:49:55 +0800</pubDate><description><![CDATA[E. Water Level

题意：初始水量为k，每天你可以使水量加y，然后每天必定消耗x的水，水量要始终在范围[L,R]中，问你能不能坚持t天

数据范围：

题解：

当x&gt;=y时，这种情况好处理，就是（1）加y超过r时，每天减少x，(2)加y合法时，此后每天减少x-y。模拟即可

当x&lt;y时，不妨不加水，让他每天只消耗水，知道水量为大于等于L的最小值（记为rst），然后再加水，重复这个过程，还有时间当时不能加水就是No

        根据数论知识，能够知道rst最后...]]></description><category></category></item><item><title><![CDATA[Codeforces Round #682 (Div. 2)]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/109954067</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/109954067</guid><author>shejunda</author><pubDate>Sun, 22 Nov 2020 15:12:25 +0800</pubDate><description><![CDATA[E. Yurii Can Do Everything

题意：

给一个长为n的数组，找到这样的区间个数——长度至少为3且端点的异或值==区间除了端点外的值的和

题解：

复杂度分析+暴力

记x，y的最高位位i，则x^y&lt;(1&lt;&lt;(i+1);

所以我们固定一个端点枚举的时候枚举到上限就可以跳出了

向左和向右分别枚举一遍，这样不会漏掉，但是会重复，可以把枚举到的区间记一下（因为区间的个数肯定是小于我们的枚举量的）

时间复杂度大概nlogn


#include&lt;bits...]]></description><category></category></item><item><title><![CDATA[Codeforces Round #685 (Div. 2)   E2 - Bitwise Queries (Hard Version)]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/109912011</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/109912011</guid><author>shejunda</author><pubDate>Sun, 22 Nov 2020 11:46:34 +0800</pubDate><description><![CDATA[F

题意：

给你长度为n的隐藏的数组，你有三种询问：选两个不同的下标i，j，询问（1）a[i]|a[j] (2) a[i]&amp;a[j] (3) a[i]^a[j]

你可以询问至多n+2次（hard verson 为n+1次）

题解：

（1）做n-1次操作——每次询问a[i]^a[i-1] (i=2,3,4.....n)

（这样把询问结果求个前缀异或和b[i]，任意两个下标i,j对应的数的异或和就是b[i]^b[j-1] (假设j&lt;i)

（2）然后有两种情况
...]]></description><category></category></item><item><title><![CDATA[D. Powerful Ksenia （codeforces round #682 div 2）]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/109725253</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/109725253</guid><author>shejunda</author><pubDate>Mon, 16 Nov 2020 17:28:40 +0800</pubDate><description><![CDATA[D. Powerful Ksenia

题意：

给一个长为n的数组，在小于等于n种操作下使得数组的所有数相同，每次操作——选定三个不同的下标i，j，k，然后a[i]=a[j]=a[k]=a[i]^a[j]^a[k]

题解：

（1）对x，x，y操作，得到y，y，y

（2）n为奇数时，可如下操作：

先1 2 3 ，3 4 5，5 6 7， 7 8 9 。。。。

得到的数列大概是 x，x，y，y，z，z。。。。。k，k，k （前面两两一组，最后三个相同）

这样做的次数是（n-1）/2

然后n-..]]></description><category></category></item><item><title><![CDATA[2020 ccpc 长春站 F - Strange Memory]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/109671497</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/109671497</guid><author>shejunda</author><pubDate>Fri, 13 Nov 2020 11:28:38 +0800</pubDate><description><![CDATA[题意：

给一颗树，每个点有权值a[i]，（u，v）合法仅当a[u]^a[v]=a[lca(u,v]，这样的点对对答案的贡献为u^v，求最后的答案（（u，v）和（v，u）视作相同点对

题解：

参考：https://blog.youkuaiyun.com/qq_45458915/article/details/109583484

dsu on tree


#include&lt;bits/stdc++.h&gt;
using namespace std;

#define ll long long
const i]]></description><category></category></item><item><title><![CDATA[Cf Round #681 (Div. 1, based on VK Cup 2019-2020 - Final)]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/109522708</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/109522708</guid><author>shejunda</author><pubDate>Thu, 05 Nov 2020 23:36:35 +0800</pubDate><description><![CDATA[（待更新）

A. Extreme Subtraction

题意：给一个数组，每次操作可以使前i个数减1，或者使后i个数减1

题解：

题目使一段区间

考虑差分变成单点修改

然后就很好做了


#include&lt;bits/stdc++.h&gt;
using namespace std;

long long sum;
int a[100005];

int main()
{
	int n,t;
	scanf("%d",&amp;t);
	while(t--){
		scanf("%d",&a]]></description><category></category></item><item><title><![CDATA[C2. Pokémon Army (hard version)]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/108790455</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/108790455</guid><author>shejunda</author><pubDate>Fri, 25 Sep 2020 11:20:54 +0800</pubDate><description><![CDATA[C2. Pokémon Army (hard version)

http://codeforces.com/problemset/problem/1420/C2


#include&lt;bits/stdc++.h&gt;
using namespace std;

#define ll long long
const int maxn=3e5+5;
int a[maxn],n;
ll ans;

void insert(int i)
{
	if(i==0||i&gt;n)return;
	if(a[i]]></description><category></category></item><item><title><![CDATA[杭电第二场 A - Total Eclipse]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/108687031</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/108687031</guid><author>shejunda</author><pubDate>Sat, 19 Sep 2020 23:00:52 +0800</pubDate><description><![CDATA[A - Total Eclipse

链接：http://acm.hdu.edu.cn/showproblem.php?pid=6763

题意：

给定一个无向图，每个点有一个点权

有这样的操作：选定一个连通块（每个点的权大于0），将所有节点的权值减一

求最少的操作次数，使得所有点的权为0

题解：并查集

依照题意，贪心地选最大的连通快，每当有点的权值减为0的时候可能会使得连通块断裂成多个，我们要维护这个过程

但是这样做会tle

那我们逆向进行这个过程：

1.权最大的点最后称为割点，所以我们按]]></description><category></category></item><item><title><![CDATA[E. Egor in the Republic of Dagestan（Codeforces Round #669 (Div. 2)）]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/108530616</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/108530616</guid><author>shejunda</author><pubDate>Fri, 11 Sep 2020 11:15:29 +0800</pubDate><description><![CDATA[E. Egor in the Republic of Dagestan

题意：给一个有向图，每条边有一个类型（0或者1），什么类型的城市就只能走什么类型的边，你需要给每个城市指定类型（0/1），使得从1到n 的最短路最长，甚至长到1无法到达n

题解：spfa

1建反向边

2dis[i][0] dis[i][1] 分别表示i为类型0/1时，从i到n的最短距离(i到n的路径上的城市类型已经指定的情况下）

3对于一条从x到y的边，边的类型为tp, dis[y][tp]=min(dis[y][tp],ma]]></description><category></category></item><item><title><![CDATA[Codeforces Round #669 (Div. 2）]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/108529781</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/108529781</guid><author>shejunda</author><pubDate>Fri, 11 Sep 2020 11:13:02 +0800</pubDate><description><![CDATA[Codeforces Round #669 (Div. 2)

A. Ahahahahahahahaha

看1多还是0多，n/2说奇数还是偶数分类


#include&lt;bits/stdc++.h&gt;
using namespace std;

int cnt[2];

int main()
{
	int t,n,x;
	scanf("%d",&amp;t);
	while(t--){
		scanf("%d",&amp;n);
		cnt[1]=cnt[0]=0;
		for(int i=1;]]></description><category></category></item><item><title><![CDATA[K-D Tree]]></title><link>https://blog.youkuaiyun.com/shejunda/article/details/107890925</link><guid>https://blog.youkuaiyun.com/shejunda/article/details/107890925</guid><author>shejunda</author><pubDate>Sun, 09 Aug 2020 11:03:15 +0800</pubDate><description><![CDATA[K-D Tree

感觉K-D Tree 是将数据组织成易于搜索的结构

剩下的就是暴力搜索和剪枝了

P3769 [CH弱省胡策R2]TATT

先排序一维（目的是当前的点只能从前面的点转移，详见cmp1）

让后按排序完的顺序询问，插入

剪枝：1.当前询问子树的左子树（右子树同）的最长长度maxl&lt;now(当前答案），不进入左子树（右子树）搜索

     2.当前子树的左子树（右子树）某个维度i的最小值minl[i]&gt;p.x[i]（当前点在此维度的值），不进入左（右）子树

...]]></description><category></category></item></channel></rss>