The order of a Tree 【HDU - 3999 】

高速窄脉冲峰值保持设计 一、目的 在激光探测领域,探测器发出的高速窄脉冲,单片机AD进行采样,很难捕捉到窄脉冲的幅值,即使使用高速AD进行采样,也存在一定的难度。因此,本方案设计了一种高速窄脉冲峰值保持电路,有助于单片机AD采样能很好的捕捉到脉冲幅值。 二、方案分析与比较 峰值保持器一般分为两种:电压型和跨导型。 方案一:电压型峰值保持器,由电压型运放、二极管、保持电容、缓冲器组成,优点是元件成本低,缺点是峰值保持存在过... 阅读详情

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:
1.  insert a key k to a empty tree, then the tree become a tree with
only one node;
2.  insert a key k to a nonempty tree, if k is less than the root ,insert
it to the left sub-tree;else insert k to the right sub-tree.
We call the order of keys we insert “the order of a tree”,your task is,given a oder of a tree, find the order of a tree with the least lexicographic order that generate the same tree.Two trees are the same if and only if they have the same shape.

Input

There are multiple test cases in an input file. The first line of each testcase is an integer n(n <= 100,000),represent the number of nodes.The second line has n intergers,k1 to kn,represent the order of a tree.To make if more simple, k1 to kn is a sequence of 1 to n.

Output

One line with n intergers, which are the order of a tree that generate the same tree with the least lexicographic.

Sample Input

4

1 3 4 2

Sample Output

1 3 2 4

题意:

给出n个数,建立一个字典序最小的二叉搜索树,构成一颗相同的树。

左子树小右子树大,用题目给的序列建好二叉搜索树,然后输出他的前序遍历。

代码:

#include<stdio.h>
#include<string.h>

int n;
int mp[100050],ans[100050];
int ll[100050],rr[100050];
int l1,l2,num;

void lol(int l,int k)
{
    if(mp[l]>=k)
    {
        if(ll[l])
            lol(ll[l],k);
        else
            ll[l]=l2;
    }
    else
    {
        if(rr[l])
            lol(rr[l],k);
        else
            rr[l]=l2;
    }
}

void ss(int l)
{
    ans[num++]=mp[l];
    if(ll[l])
        ss(ll[l]);   //zuo
    if(rr[l])
        ss(rr[l]);      //you
}

int main()
{
    while(~scanf("%d",&n))
    {
    	int k;
        memset(ll,0,sizeof(ll));
        memset(rr,0,sizeof(rr));
        l1=-1,l2=0,num=0;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&k);
            if(l1==-1)
                mp[++l1]=k;
            else
            {
                mp[++l2]=k;
                lol(l1,k);
            }
        }
        ss(l1);
        for(int i=0; i<num-1; i++)
            printf("%d ",ans[i]);
        printf("%d\n",ans[num-1]);
    }
    return 0;
}

 

第三节:Vben Admin登录对接后端login接口 上一节,我们梳理的Vben Admin登录功能接口的逻辑,本节开始正式开启后端的开发后端我们采用Python的Flask项目,Flask-SQLAlchemy管理数据库模型,Flask-Migrate进行模型迁移。参考版本如下:Flask3.0.23.1.1本节,我们已经开启的后端的开发,因为是主要介绍Vben Admin的登录逻辑,所以Flask开发这里只截取了部分主要代码。 阅读详情

相关推荐

数字IC后端设计实现之Innovus POD V2 Flow性能优化全解析

本文深入解析了数字IC后端设计中的Innovus POD V2 Flow性能优化方案。该流程通过整合place_opt_design与clock_opt_design命令,实现了布局与时钟树的协同优化,有效提升了时序收敛效率、改善了设计密度与拥塞,并显著减少了迭代次数,是应对先进工艺复杂设计的关键利器。

ik6789012的博客 1254

HDU(3999)The order of a Tree

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:1.insert a key k to a empty tree, then the tree become a tree withonly one node;2.in...

weixin_30399055的博客 213

因果推断--PSM的原理和应用(二)

上一篇介绍了DID,本文介绍和DID可一起搭配使用的一种因果推断方法PSM。在正式介绍PSM之前,先来简单回顾一下为什么需要因果推断以及如何做因果推断。我们都知道相关非因果,比起相关我们更希望知道两个事件之间的因果关系,有了确切的因果关系,才能知道对A如何操作才能引起B的变化。解决因果推断问题,目前主要有两种框架,Rubin虚拟事实模型和Pearl因果图模型。站在数据分析的角度上,Rubin虚拟事实模型更容易理解,其核心思想是寻找恰当的对照组。

baidu_26137595的博客 1万+

HDU1710---树(知前序遍历与中序遍历 求后序遍历)

知前序遍历与中序遍历 求后序遍历 #include<iostream> #include<cstring> #include<queue> #include<cstdio> using namespace std; bool fist; const int maxn=1005; struct tree_node { ...

weixin_30632883的博客 131

瑞芯微RK3568开发板实战:Android11系统parameter.txt文件配置全解析(附常见问题排查)

本文深入解析了瑞芯微RK3568开发板在Android 11系统下parameter.txt文件的配置要点与实战技巧。作为BootLoader启动阶段的核心蓝图,该文件决定了硬件初始化、分区布局及电源管理。文章详细拆解了身份标识、GPIO控制(PWR_HLD)、命令行参数及分区表等关键字段的配置逻辑,并针对RK3568平台与Android 11特性提供了专项适配策略,最后附带了启动失败、分区异常等常见问题的深度排查方法。

php55的博客 896

【商业化】【msix打包】Python 应用打包为 MSIX 的正确流程:入口点问题与解决方案

发现用msix打包工具打包python做的exe时总找不到程序入口点,后来理了一下才发现自己误会了,需要先生成一个基本的setup.exe,msix的打包是基于这个初始的安装程序进行的。只需要点击Buile-》Compile,然后Open Output Folder就可以得到exe安装程序了。可以使用免费工具inno setup来创建初始安装包。其中{group}这样的变量会自动匹配,不用自己指定。如果点击Run会运行安装程序。

每日出拳老爷子的博客 1105

The order of a Tree( 树的顺序)

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1.insert a key k to a empty tree, then the tree become a tree with only one node;...

shiuxin的博客 648

SAP 针对不同行业(制造业、零售业、金融业)推出了专属的云解决方案,以下是各行业的核心方案与特点

SAP推出行业专属云解决方案:制造业(SAP Digital Manufacturing Cloud)提供AI排产与质量预警,降低缺陷率;零售业(S/4HANA Cloud零售版)实现AI预测补货与全渠道库存同步,减少浪费;金融业(Business ByDesign)支持合规自动化与实时风控,降低审计成本。各方案均采用云原生架构,典型案例显示实施效果显著。

金牌架构师 494

The order of a Tree

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1.  insert a key k to a empty tree, then the tree become a tree with only one node; 2. ...

沈君乱 261

PCL 计算点云包围球【2025最新版】

包围球通常用于简单排斥,因为与球体相交的方程很简单,同样重要的是,旋转一个球体并不会改变其范围。因此,当包围球用于简单排斥时,如果球体中心是对象的原点,则可以忽略对象的方向。

点云侠的博客 2068

AI Agent在智能腰带中的姿势矫正与提醒

随着人们生活方式的改变,长时间不正确的坐姿、站姿等不良姿势问题日益普遍,这不仅会导致身体疲劳,还可能引发颈椎病、腰椎病等多种健康问题。智能腰带作为一种可穿戴设备,具有实时监测人体姿势的潜力。本研究的目的是将AI Agent引入智能腰带,实现对人体姿势的准确识别、矫正与提醒功能。本研究的范围涵盖了从AI Agent的核心算法原理到智能腰带的实际开发与应用。包括传感器数据的采集与处理、机器学习算法的选择与训练、智能腰带的硬件设计与软件开发,以及在不同场景下的实际应用测试。本文共分为十个部分。

AI 原生应用开发的博客 344

HDU3999 The order of a Tree

HDU3999 The order of a Tree 复习二叉树ing 题目地址 创建一个二叉树,小于根的数放左子树,大于的放右子树,输出和这个数相同的最小字典序,嘛,翻译解释的肯定比我解释的好。 要字典序最小,正好为树的前序遍历,前序遍历并输出就好了。 代码如下: #include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; typed

fatekingsama的博客 177

【AI智能体】Codex + Seedance2.5 制作AI视频实战操作详解

【AI智能体】Codex + Seedance2.5 制作AI视频实战操作详解

congge_study的博客 3822

HDU 3999 The order of a Tree

今天回学校了,准确的说是昨天回来的,今天第一天来机房,暑假搞的东西欠下的债不少,然后补补题 发现是个大水题 The order of a Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4235 Accepted Submission(s): 2151 Problem Description As we know,the .

苦鬼·。 231

深度学习工具包 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'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('DeepLearnToolbox'));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('state',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'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',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 = 'sigm';%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, 'Too big error');```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('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';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)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';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, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% 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'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 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, 'Too big error');```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('state',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, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',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, 'Too big error');%% ex3 neural net with dropoutrand('state',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, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % 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, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % 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, 'Too big error');%% 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('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % 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, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

hdu 3999 The order of a Tree

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3999 The order of a Tree Description As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be preci...

dong12276的博客 95

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

HDU 3999 The order of a Tree 二叉树

二叉树的先序遍历

NeWnIx 820

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

hdu 3999 The order of a Tree

题目链接:点击打开链接 Problem Description As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1.  insert a key k to a empty tree, then the t

Vision 374

HDU3999-The order of a Tree

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: insert a key k to a empty tree, then the tree become a tree with only one node; insert...

weixin_43357583的博客 174

hdu 3999The order of a Tree

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3999 本题为简单二叉排序树,先按排序树创建树,然后先序遍历二叉树,输出的时候最后一个数字后面没有空格。 数组实现:   #include #include #define N 100005 int tree[N],left[N],right[N],a[N],num,flg;//tree数

为编程而生 732

hdu3999 The order of a Tree二叉搜索树

Problem Description As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1. insert a key k to a empty tree, then the tree become a tree

bayleexu 510

The order of a Tree hdu3999 二叉搜索树

题目链接: hdu3999 The order of a Tree 题意: 给一个二叉搜索树的序列,求输出可以构成这个二叉搜索树的且满足字典序最小的插入序列 找了一个比较具体描述怎么根据序列建立二叉搜索树的 图片来自:https://blog.csdn.net/qq_39290830/article/details/85197994 思路: 首先,根据输入键的顺序,构造对应的二叉搜索树;然后,前序遍历这棵二叉树,得出的 树的顺序就是以最小的字典序生成的相同形状的树。 #include <iostre

CUCUC1的博客 268

HDU - 3999 The order of a Tree

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:  1.  insert a key k to a empty tree, then the tree become a tree with  only one node;  ...

GJLfly的博客 188

HDU3999:The order of a Tree

Problem Description As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1.  insert a key k to a empty tree, then the tree become a tree w

ACM!荣耀之路! 2066
上一篇: Trees on the level【 HDU - 1622 】
下一篇: Not so Mobile[ UVA - 839]
Daisy's一乐景三
博客等级 码龄8年 2粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值