传送门 题意是给定一棵树,然后一种操作是指定一个点,这个点及这个点的的子树被染色,另一种操作是指定一个点,问这个点的颜色。 用dfs序建线段树。思路相当于,把当前节点管理所有儿子节点,转换为当前节点对应一条包含所有儿子的线段, 如何转换呢?dfs的时候,访问到当前节点x后,给节点x一个在线段树中的下标cnt,即节点x在线段树中对应的起点,记录为L[x]=cnt,继续深入,重复之前的操作,cnt不断加1。dfs再次返回到x时,我们知道节点x所管理的儿子在线段树中的终点为cnt,记录为R[x]=cnt,那么x节点对应的线段在线段树中为[L[x],R[x]],这样就完成了树到线段树的映射。 之后就...

  ecCNZqUYvVPu   2023年11月02日   44   0   0 线段树#includei++

TheCastle TimeLimit: 1000MS   MemoryLimit: 10000K TotalSubmissions: 8241   Accepted: 4648 Description 1234567 1|||| ------------ 2| ------------ 3|| ------------ 4|||| (Figure1) =Wall |=Nowall =Nowall Figure1showsthemapofacastle.Writeapr...

  ecCNZqUYvVPu   2023年11月02日   51   0   0 深搜#includePOJi++二维数组

这个注意精度的问题,if好像小数后面比较不太准确。 include<iostream> include<cstdio> include<algorithm> include<cmath> intmain() { intn; scanf("%d",&n); while(n--) { doubleh,t; scanf("%lf%lf",&h,&t); h=(h100)1.8; if(fabs(ht)10<h)//这个地方把10除到右边来就不对 printf("Youarewanmei!\n"); elseif(t&g...

  ecCNZqUYvVPu   2023年11月02日   39   0   0 #includeios

传送门 include<bits/stdc.h> defineintlonglong usingnamespacestd; constintMAXN=50010; pair<int,int>P[MAXN]; signedmain(){ //freopen("in","r",stdin); ios::sync_with_stdio(false); intN; cin>>N; for(inti=1;i<=N;i){ cin>>P[i].first>>P[i].second; P[i].first+=P[i].second; ...

  ecCNZqUYvVPu   2023年11月02日   33   0   0 C++i++ci

算是有史以来打得最好的一场了吧,出了题, A.BowWowandtheTimetable include<bits/stdc.h> defineintlonglong usingnamespacestd; chars[300]; signedmain(){ cin>>(s+1); intn=strlen(s+1); if(n1){ cout<<0<<endl; return0; } intf=0; for(inti=1;s[i];i) if(s[i]'1') f; intx=n1>>1; x; if(f1&&n%...

  ecCNZqUYvVPu   2023年11月02日   50   0   0 C++i++ci

题目大意就是说有2N个人要平均分进两个队伍里去,然后每对不在同一队伍里的人会产生竞争值,题目中给了每两个人产生的竞争值,问怎样分配能使得竞争值最大化。 思路就是先默认所有的人都在一个队里,然后每次DFS暴力枚举这个人是不是分进另一个队伍里,最后取最大值即可。 include<bits/stdc.h> defineintlonglong usingnamespacestd; intx[30][30],d[30],n,ans; vector<int>w; voidDfs(intp,intres) { if(w.size()n) { ans=max(res,ans); r...

  ecCNZqUYvVPu   2023年11月02日   53   0   0 cic++i++
关注 更多

空空如也 ~ ~

粉丝 更多

空空如也 ~ ~