[计数][容斥] LOJ#6065 || BZOJ4927 && 2017 山东一轮集训 Day3. 第一题

LOJ6066:「2017 山东一轮集训 Day3」第二题 传送门 二分答案 kkk,考虑如何 hashhashhash 使得做起来方便 把每个点挂在 k+1k+1k+1 级祖先上,考虑在祖先上删除 这道题巧妙在于其可以对于 dfsdfsdfs 序/括号序列 hashhashhash 这样在 k+1k+1k+1 级祖先上暴力删除就好了 # include <bits/stdc++.h> using namespace std; typedef ... 阅读详情

因为要选6根木棒,发现肯定是1,1,2,2或1,1,1,3形式。
可以枚举2和3的部分,然后推一推,容斥容斥就可以了
但是细节贼多

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N=5010,MAX=1e7;

typedef long long ll;

int n,a[N];
ll num[MAX+10],dnum[MAX+10],vis[MAX+10],ans;
vector<int> b;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

inline void rea(int &x){
  char c=nc(); x=0;
  for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
}

int main(){
  rea(n);
  for(int i=1;i<=n;i++){
    rea(a[i]),num[a[i]]++;
    if(!vis[a[i]]) b.push_back(a[i]);
    vis[a[i]]=1;
  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      if(a[i]+a[j]<=MAX && a[i]<a[j]) dnum[a[i]+a[j]]++;
  for(int u : b)
    if(num[u]>=2){
      ll x=1LL*num[u]*(num[u]-1)/2,cur=0;
      if(u%2==0 && num[u/2]>=4)
    ans+=x*num[u/2]*(num[u/2]-1)*(num[u/2]-2)*(num[u/2]-3)/24;
      for(int v : b)
    if(v<u && num[v]>=2 &&num[u-v]>=2 && v<u-v)
      cur+=num[v]*(num[v]-1)*num[u-v]*(num[u-v]-1)/4;
      ans+=x*cur; cur=0;
      for(int v : b)
    if(v<u && num[u-v] && v<u-v)
      ans+=x*cur*num[v]*num[u-v],cur+=num[v]*num[u-v];
      if(u%2==0)
    ans+=x*cur*num[u/2]*(num[u/2]-1)/2;
    }
  for(int u : b)
    if(num[u]>=3){
      ll x=1LL*num[u]*(num[u]-1)*(num[u]-2)/6,cur=0;
      if(u%3==0 && num[u/3]>=3)
    ans+=x*num[u/3]*(num[u/3]-1)*(num[u/3]-2)/6;
      for(int v : b)
    if(v<u){
      cur+=1LL*num[v]*dnum[u-v];
      if(v+v<u && v+v+v!=u ) cur-=1LL*num[v]*num[v]*num[u-v-v];
    }
      ans+=cur*x/3;
      for(int v : b)
    if(v*3!=u && v*2<u) ans+=x*num[v]*(num[v]-1)/2*num[u-v-v];
    }
  printf("%lld\n",ans);
  return 0;
}
VMware桥接模式实战:用手机热点给Linux虚拟机共享网络(附WiFi适配技巧) 本文详细介绍了在移动办公场景下,如何为VMware中的Linux虚拟机配置桥接模式,以通过手机热点共享网络。文章深入解析了桥接模式在无线环境下的工作原理,提供了从主机端准备、VMware设置到Linux虚拟机内部配置的完整实战步骤,并针对手机热点的特殊性,分享了MTU优化、DNS配置及常见网络问题的诊断与解决方案,帮助用户实现稳定高效的移动虚拟化办公。 阅读详情

相关推荐

纽马克-贝塔法(Newmark-Beta Method)在结构动力学中的应用与实现

本文深入解析了纽马克-贝塔法(Newmark-Beta Method)在结构动力学数值计算中的核心原理与应用。作为经典的时间积分算法,它通过调节γ和β参数,在计算精度、稳定性与效率间取得平衡,尤其适用于地震响应、风振分析等工程场景。文章详细阐述了其数学内核、在有限元分析中的实现步骤,并对比了隐式与显式方案的适用场景,为工程师提供了关键的方法选择与参数调优指导。

weixin_29232121的博客 151

LOJ.6066.[2017山东一轮集训Day3]第二题(树哈希 二分)

LOJ 被一件不愉快的小事浪费了一个小时= =。 表示自己(OI方面的)智商没救了=-= 比较显然 二分+树哈希。考虑对树的括号序列进行哈希。 那么每个点的\(k\)子树的括号序列,就是一段区间去掉距离它为\(k+1\)的点的子树的区间。那么我们把每个点放到它的\(k+1\)级祖先上,在\(k+1\)级祖先处求哈希值时,跳过这个点的括号区间即可。 至于具体的哈希方式...xjb哈希就行了 //...

weixin_30827565的博客 212

芯片详解——AD7606

AD7606详解

weixin_45661757的博客 5043

[树的同构][二分][可并堆维护哈希] LOJ#6066 || BZOJ4928 && 2017 山东一轮集训 Day3. 第二题

这题一看就可以二分 那么解决这题的关键就变成了怎么对树进行哈希,以及怎么快速维护哈希值 想了一个下午想了一个比较靠谱的哈希方法。 用一个p进制数(p>n且为质数)来表示每一个节点,这个数有depth位,depth位这个节点的深度,那么这个数在p进制下第i位表示这个点的depth-i的祖先是其父亲的第几个儿子。 大概长这样 子树中所有节点的哈希值之和作为这个子树的哈希值。 因为每个哈希值的

CE玩家 1074

Matlab实战:用卡尔曼滤波搞定无人机GPS轨迹优化(附完整代码)

本文详细介绍了如何使用Matlab实现卡尔曼滤波(KF)算法优化无人机GPS轨迹,提供完整代码和工程实践指南。通过线性卡尔曼滤波技术,有效降低定位噪声,提升轨迹平滑度,适用于无人机导航和控制系统开发。

weixin_29061425的博客 258

映泰TB250-BTC主板魔改BIOS支持8/9代CPU实战与开机故障排查

BIOS(基本输入输出系统)是计算机硬件与操作系统之间的桥梁,负责初始化硬件和提供运行时服务。其工作原理是通过存储在主板芯片中的固件程序,在上电自检(POST)阶段完成对CPU、内存等关键组件的检测与配置。魔改BIOS的技术价值在于突破硬件限制,通过修改微码和电源管理模块,让旧平台支持新处理器,从而以极低成本实现性能跃升,在预算有限或追求极致性价比的DIY、办公和软路由等应用场景中极具吸引力。本文以映泰TB250-BTC矿板为例,详细解析了通过软刷方式刷入魔改BIOS,并重点解决了刷写后常见的“开机风扇转一

weixin_29164185的博客 427

[费用流]LOJ#6079. 「2017 山东一轮集训 Day7」养猫

DescriptionDescription你养了一只猫,为了让它快乐地成长,你需要合理地安排它每天的作息时间。假设一天分为nn个时刻,猫在每个时刻要么是吃东西,要么是睡觉。在第ii个时刻,假如猫是去吃东西,那么它能获得愉悦值eie_i​,假如是去睡觉,那么能获得的愉悦值为sis_i 。猫要成长,不仅仅需要快乐,还需要健康的作息。经过研究,对于每一个连续的长度为kk的作息区间,即所有的时刻区间[i,

Vectorxj的博客 1385

飞腾Ubantu22.04.3安装OpenNebula测试

因OpenneBula官方镜像源只有AMD架构的镜像包不存在ARM的镜像包,借此用源码编译进行测试。

坚持就是胜利的博客 1018

【2017山东day7】养猫

【2017山东day7】养猫 Description   你养了一只猫,为了让它快乐地成长,你需要合理地安排它每天的作息时间。假设一天分为$ n \(个时刻,猫在每个时刻要么是吃东西,要么是睡觉。在第\) i $个时刻,假如猫是去吃东西,那么它能获得愉悦值 \(ei\),假如是去睡觉,那么能获得的愉悦值为 \(si\)。   猫要成长,不仅仅需要快乐,还需要健康的作息。经过研究,对于每一个连续的长...

weixin_34227447的博客 345

数字IC设计随笔之二(VCS、DVE|Verdi单步调试)

VCS+Verdi单步调试

ic疾风传 1万+

Keil5编译报错:ARM Compiler Version 5缺失的完整解决方案

本文提供了Keil5编译报错“ARM Compiler Version 5缺失”的完整解决方案。详细介绍了手动安装ARM Compiler Version 5的步骤,包括下载安装包、配置编译器路径及常见问题排查,帮助开发者快速恢复老项目的编译环境。

bb456的博客 951

LOJ6079「2017 山东一轮集训 Day7」养猫

养ImmortalCO k可重区间问题 的增强版:有上下界! 直接都选择s[i],然后再把一些调整到e[i] 考虑通过最大流的“最大”,使得至少每k个有me个e, 通过最大流的“上界”,限制每k个最多有k-ms个e 麻烦的是第一个要求。 建图方式: 开始ans+=∑s[i] 1.每个点i到i+k,(1,e[i]-s[i]) 2.每个点i到i+1,(k-ms-me,0)...

weixin_34384681的博客 209

RK3588平台MIPI DSI屏幕调试记录

本文是基于RK3588平台,MIPI屏调试总结。调试过程中遇到的问题:一开始很久没亮,测量了电源电压和波形都正常。后来换了一组板子和屏幕做对比。最后是因为屏幕的座子没焊接好,二是接MIPI屏幕的排线太长会影响数据传输。换了一根短的线之后屏幕亮起。vp2vp3。

bingdund的博客 1398

【LOJ #6079】. 「2017 山东一轮集训 Day7」养猫(最大费用最大流)

传送门 考虑先全部选sss,再改一些成eee 考虑 (i,i+1,k−ms−me,0)(i,i+1,k-ms-me,0)(i,i+1,k−ms−me,0)代表不改成eee (i,i+k,1,ei−si)(i,i+k,1,e_i-s_i)(i,i+k,1,ei​−si​)代表改成eee 建一个虚点xxx像1−k1-k1−k连(inf,0)(inf,0)(inf,0) (str,x,k−ms,0)(s...

Stargazer的博客 409

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

【树hash】「2017 山东一轮集训 Day3」第二题

题目 求形态相同的两个最大k-子树。k-子树定义为从u节点到其子树中距离不超过k的所有节点。 题解 树hash,因为我们要从树中选一部分来当k-子树,所以考虑用欧拉序来hash。 用欧拉序的话,如果我们要删一部分,距离超过k的节点的子树时,只需要删in[v]->ou[v]的hash就行了 (但我们发现如果in[v],ou[v]分别用不同的数字表示即可表现树,因为这样的括号序列对应的树的形态是...

ygmjsjdboy的博客 238

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LOJ 6100 「2017 山东二轮集训 Day1」第一题

可持久化线段树+二分注意到如果[l,r]不降,[l,r-1]就肯定也不降,因此如果能对于每一个位置l,找到最远的r满足不降。这样套上主席树问题就搞定了。会降当且仅当此时异或上的a[i]的最高位恰好把当前的这一位从1变成0。因此记f[i][j][0/1]f[i][j][0/1]表示从a[1]开始异或到a[i],以j为最高位的时候,j从1变成0(或0变成1)有多少次。这样二分以后每一位都判一下即可。O(

无尽 1282

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

BZOJ 5460 LOJ #6060. 「2017 山东一轮集训 Day1 / SDWC2018 Day1」Set

Description 给出 n 个非负整数,将数划分成两个集合,记为 1 号集合和 2 号集合。 x1 为 1 号集合中所有数的异或和, x2 为 2 号集合中所有数的异或和。在最大化 x1+x2 的前提下,最小化 x1。 题解: 好题啊! 容易想到按位考虑,记所有数的异或和为SSS,那么从高到低位考虑,若某个位上的数为111,那么意味着这个位上一共有奇数个111,无论怎么分配,x1x_1x1​...

TYB的博客 871

BZOJ 4927 第一题

题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=4927 题解 6个木棍拼成一个正方形,只有下面两种情况: 第一种情况 排序,先枚举蓝色边,再枚举红色边,那么绿色边+黄色边的值已经确定了,记sum[i]sum[i]sum[i]表示两条边之和为iii的方案数,对于每个枚举到的蓝色边...

dilei7762的博客 179

[bzoj4927][SDOI省队集训2017]diyiti

题目大意在一个长度为n的数列中找出六个数,使得可以把它们分成四组,每组的和均相等。求方案数。XJB做只有1+1+1+3或1+1+2+2两种拆分。 先预处理two[x]表示找出两个数和为x的方案数,以及one[x]表示有多少数是x。 对于1+1+1+3,枚举那个1是x,首先有一个C3one[x]C_{one[x]}^3。 对于那个3,我们先枚举一个ai,然后对应方案数是two[x-a[i]]。

不来也不去的一只失忆蝴蝶 920

[LOJ#6066]. 「2017 山东一轮集训 Day3」第二题[二分+括号序列+hash]

题意 题目链接 分析 首先二分,假设二分的答案为 \(mid\),然后考虑利用括号序列来表示树的形态。 点 \(u\) 的 \(k-\) 子树的括号序列表示实际上是刨去了 \(u\) 子树内若干个与 \(u\) 距离为 \(mid\) 的点的一段连续的括号序列,挂链即可。判断括号序列是否相同可以考虑哈希。 总时间复杂度 \(O(nlog^2n)\)。 代码链接 转载于:https...

aqw145212的专栏 229

HDU 6065 RXD, tree and sequence(在线倍增LCA+CDQ分治+离线tarjan-LCA+dp)

Description 给出一棵n个节点的树和一个1~n的排列,要求把该排列分成k个连续的段,使得每段点在树上的LCA深度之和最小 Input 多组用例,每组用例首先输入两个整数n和k,之后输入一个1~n的排列,最后n-1行每行两个整数u和v表示u和v之间有一条树边,以文件尾结束输入 (1<=k<=n<=3e5,n*k<=3e5) Output 输出将该排列分成k段后每段LCA深度之和最

ZSQ 650

【LOJ#6066】「2017 山东一轮集训 Day3」第二题(哈希,二分)

【LOJ#6066】「2017 山东一轮集训 Day3」第二题(哈希,二分) 题面 LOJ 题解 要哈希是很显然的,那么就考虑哈希什么。。。 要找一个东西可以表示一棵树,所以我们找到了括号序列。 那么二分一个答案\(d\),把所有点挂到\(d+1\)次祖先上去,那么\(d+1\)次祖先的哈希值就是它原本的括号序列挖去了若干段,直接暴力哈希拼接起来就好了。 #include<iostream&...

weixin_30278237的博客 216

「2017 山东二轮集训 Day3」第一题

题目描述 体节 贪心,每人每次分给的一定是所需代价最小的v[i]−1v[i]-1v[i]−1个,且分给他的只需要比上一个人多一个。 代码 #include &lt;stdio.h&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cstring&gt; #define ll long long using...

include / Hdhd 2286

「LOJ6066」「2017 山东一轮集训 Day3」第二题-树hash

Description 链接 考虑对括号序列进行哈希。 二分答案kkk。考虑一个点的k−k-k−子树就是它的子树去掉距离它大于kkk的节点,对应到括号序列上就是一个大区间减去若干个小区间。把每个点挂在它的k+1k+1k+1级祖先上,然后计算即可。 Solution 考虑对括号序列进行哈希。 二分答案kkk。考虑一个点的k−k-k−子树就是它的子树去掉距离它大于kkk的节点,对应到括号序列上就是一个...

DSL_HN_2002的博客 473

loj#6100. 「2017 山东二轮集训 Day1」第一题 主席树+二分

题目描述: 小火车沉迷垃圾手游不能自拔,正在玩碧蓝航线,可惜小火车的舰(lao)队(po)练度太低打不过副本,所以他只好去刷其余的副本来升级。 总共有 n 个副本编号从 1 到 n ,每个副本有个难度值 a_i,小火车每天按照顺序刷连续的一段副本,第 j 天会刷的副本必须落在 l 到 r 之间。但是他是个很懒的人,每天一开始他的懒惰值为 0,当他刷完一个副本以后懒惰值就会异或上 a_i ,...

TYB的博客 566

LibreOJ #6060.「2017 山东一轮集训 Day1 / SDWC2018 Day1」Set 线性基

题意 给出n个非负整数,将数划分成两个集合,记为一号集合和二号集合。x1为一号集合中所有数的异或和,x2为二号集合中所有数的异或和。在最大化x1+x2的前提下,最小化x1。 n≤105,ai≤1018n≤105,ai≤1018n\le10^5,a_i\le10^{18} 分析 设sss表示所有数的异或和,那么我们就是要找一个最小的x1满足x1+x1 xor s最大。 考虑对于每一位分...

beginend 732
上一篇: [线段树][二分图 霍尔定理]LOJ#6062 && 2017 山东一轮集训 Day2. Pair
下一篇: [树的同构][二分][可并堆维护哈希] LOJ#6066 || BZOJ4928 && 2017 山东一轮集训 Day3. 第二题
LowestJN
博客等级 码龄10年 76粉丝 422原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值