codeforces 675D Tree Construction(set)

手把手教你用UNet实现轨道缺陷检测(附RSDDs数据集下载与完整代码) 本文详细介绍了如何使用UNet模型实现轨道缺陷检测,包括RSDDs数据集的下载与处理、UNet架构的改进与优化、训练策略设计以及模型部署的全流程。通过实战案例,展示了如何利用深度学习技术提升工业质检效率,特别适合从事工业缺陷检测和图像处理的开发者参考。 阅读详情

转自http://blog.youkuaiyun.com/qq_21057881/article/details/51439406
//题意:
给你n个节点,第一个节点作为根节点,接下来的如果节点值>他的父节点,就将他练到他的右边,否则练到左边,输出从2–n节点的父节点的编号。



    #include<iostream>  
    #include<cstdio>  
    #include<map>  
    #include<set>  
    using namespace std;  
    const int maxn = 1e5+6;  
    map<int,int>pos;  
    set<int> s;  

    int main()  
    {  
        int n;  
        scanf("%d",&n);  
        int temp;  
        scanf("%d",&temp);  
        s.insert(0);  
        s.insert(temp);  
    //  s.insert(1e9+100);  
        pos[temp]=1;  

        for (int i = 2;i<=n;i++)  
        {  
            cin >> temp;  
            set<int>::iterator it = s.lower_bound(temp);  
            set<int>::iterator it1 = it;  
            set<int>::iterator it2 = it;  
            it1--;  
            if (pos[*it1]>pos[*it2])  
                 printf("%d\n",*it1);  
            else  
                printf("%d\n",*it2);  
            s.insert(temp);  
            pos[temp]=i;  
        }  
        printf("\n");  
    } 
[Python] -项目实战10- 用 Python 自动化批量重命名文件 本文介绍了使用Python实现文件批量重命名的技术方法。主要内容包括:1)使用os和pathlib模块进行基础文件操作;2)提供多种实用脚本示例,如添加序号、替换字符、添加时间戳等;3)进阶功能包括用户输入和错误处理;4)GUI工具实现方案;5)常见问题与优化建议。文章详细讲解了从简单到复杂的批量重命名实现方法,帮助读者快速掌握这一提高工作效率的技能。建议开发者注意路径处理、错误管理等细节,确保脚本稳健运行。 阅读详情

相关推荐

基于STM32的Modbus TCP多主站数据监测

Modbus TCP通信协议在STM32上实现,STM32作为服务器采集内部传感器数据,并通过ADC进行转换,存入寄存器。两个PC机作为客户端访问服务器,服务器通过Socket通信实现监听连接,将数据发送给客户端。

hyp12347的博客 4292

Codeforces 675D Tree Construction【思维+set】

D. Tree Construction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output During the programming classes Vasya was assigne

mengxiang000000 898

别再手动调参了!用MATLAB+改进PSO算法,5步搞定机械臂轨迹优化(附完整代码)

本文介绍如何利用MATLAB和改进PSO算法快速优化机械臂轨迹规划,仅需5步即可完成传统耗时的手动调参过程。通过混沌初始化、自适应权重等创新方法,改进PSO算法显著提升优化效率,实现全局最优解搜索,适用于工业自动化中的机械臂控制。文章包含完整MATLAB代码实现,帮助工程师轻松应用于实际生产场景。

weixin_29232121的博客 353

codeforces-675D-Tree Construction(思维 用set模拟二叉搜索树)

题目 给定一个有 N 个数组成的序列,在此基础上构建一棵二叉排序树,求每个节点(根节点除外)的父节点的编号是多少。 输入输出样例 输入样例#1 3 1 2 3 输出样例#1: 1 2 输入样例#2: 5 4 2 3 1 6 输出样例#2: 4 2 2 4 说明 题解:自己造一个二叉搜索树 TLE了。 一个节点的父节点是它前面的数中 比它大的的最小的,比它小的最大的。两个谁出现的位置晚。就是它的父...

qq_42576687的博客 247

微信小程序 | 小程序开发

事实上,目前小程序在我们生活中已经随处可见(特别是这次疫情的推动,不管是什么岗位、什么年龄阶段的人,到哪都需要打开健康码)WePY是由腾讯开源的,一款让小程序支持组件化开发的框架,通过预编译的手段让开发者可以选择自己喜欢的开发风格去开发小程序。Mpvue是一个使用Vue开发小程序的前端框架,也是 支持 微信小程序、百度智能小程序,头条小程序 和 支付宝小程序;微信小程序、支付宝小程序、淘宝小程序、抖音小程序、头条小程序、QQ小程序、美团小程序等。,其他平台的小程序往往是平台本身的一些公司或者顺手开发的。

CoderHing的博客~ 1万+

树莓派4B保姆级教程:从零配置Python虚拟环境到PySide2开发全流程(含避坑指南)

本文提供树莓派4B上配置Python虚拟环境及PySide2 GUI开发的完整教程。针对armv7l架构的特殊性,详细讲解了从系统准备、虚拟环境创建到PySide2安装的避坑指南,并重点解决了跨平台UI文件处理等常见难题,帮助开发者构建稳定高效的开发环境。

9q8w7e6r5的博客 822

华为OD机试新系统真题-谁没交卷(Java /Py/C++/Go/C/Js)

华为OD机试 新系统真题【谁没交卷】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【谁没交卷】多语言题解。

qq_45776114的博客 421

Codeforces 675C Money Transfers 【思维】 + 675D Tree Construction 【二分】

题目链接:Codeforces 675C Money TransfersC. Money Transfers time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output There are n banks in the city where

世界很大 989

杰理JL7033C芯片运行SoundFont音色库教程

本教程介绍如何在杰理JL7033C芯片上移植TinySoundFont音色库,实现MIDI播放功能。关键步骤包括:获取TinySoundFont开源代码,创建音色库声音播放数据流,封装核心功能文件。硬件需配备外部PSRAM和NOR FLASH存储音色库,软件使用杰理SDK和工具链。移植后系统可支持40个voice,满足MIDI播放和电子琴演奏需求。教程详细说明了代码移植过程,包括音色库文件处理、内存配置和音频流水线设置。

qq_42014563的博客 610

关于在线excel插件Univer笔记教程

univer在线excel插件确实是够强大,但也存在不少bug,用户用起来是真的很爽,和本地的wps差不多,但真正的开发起来是真的费劲。由于文档提供的信息不足,我们很多功能只能去看他们插件里的源代码,然后一点点测试,一点点尝试研究。此文章可省去五天的研究成本

guiplan 5825

Codeforces 675D Tree Construction

D. Tree Construction During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so he asks you to...

Low Coder的博客 518

c#仿热血江湖

Int32_1 = (int) table.Rows[i]["FLD_初级附魂"],Int32_2 = (int) table.Rows[i]["FLD_中级附魂"],Int32_3 = (int) table.Rows[i]["FLD_是否绑定"],Int32_0 = (int) table.Rows[i]["FLD_进化"],Form1.smethod_1(2, "加载百宝阁物品----没有百宝阁数据");Form1.smethod_1(2, "加载物品商店----没有物品数据");

weixin_42132177的博客 142

codeforces 675D Tree Construction

http://www.codeforces.com/problemset/problem/675/D 给定一段数列(数列中每个数值不同),按顺序插入到一棵初始为空的排序二叉树中。求树的最终形态(每个点的父亲)。2<=n<=1e5 这种不难但是需要一点数学思维的题目很能锻炼人思维的灵活性,拿来考察状态是很不错的。 首先直接模拟肯定会被卡,这一点应该有充分的警觉性。 我们...

amoyp88606的专栏 144

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

深度学习工具包 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")

Codeforces 675D. Tree Construction(二叉搜索树性质)

题目: http://codeforces.com/problemset/problem/675/D 题意: n个不同的数,依次按要求插入二叉搜索树中,输出每个数的父节点是谁。 要求如下: 1.第一个数是根节点; 2.插入a[i]时,从根节点开始向下走,若当前节点的数&amp;amp;lt;a[i],向右走,否则向右走,若走不下去则生成新节点并赋权值为a[i]。 分析: 性质①: a[i]要么是a[1] ~a[i...

OI -> ACM -> AI 465

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

STL乱搞 Codeforces675D Tree Construction

传送门:点击打开链接 题意:按BST插入节点。最后输出每个节点的父节点的值是多少 思路:这场的cf脑洞都很大。。 首先,假如我们要插入的节点的值为x,我们发现父节点的值一定是x的最小值的左节点 然后我们还能发现,每次x的最小值的左节点,这2个位置,总是只有1个位置已经在之前被放了节点了,总是只有一个位置是空着的 那么x就应该放在这个位置了(@#$%^&* #include #incl

qwb的博客 849

codeforces 675D Tree Construction (map)

题目链接:http://codeforces.com/contest/675/problem/D 题意:建立一棵二叉搜索树,比当前节点小的放左边,否则放右边。问编号2~n的节点的父节点数值是多少。 思路:如果用普通的建树方法来做,在遇到深度较深的树时会超时。map的lower_bound(t)返回第一个key大于等于t的位置it,所以t必定在(it.second,it.firs

West___wind的博客 370

Codeforces 675D Tree Construction【构造,BST】

题目链接:http://codeforces.com/contest/675/problem/D题意:给定数列,依次插入二叉树,求子节点的父节点。分析:根据二叉树的性质,我们可以找到大于这个数的最小值和小于这个数的最大值,这两个数即为该数的父节点,那么如果结点对应的儿子结点为空,直接放进去即可。注意由于这两个数的性质不存在两个结点都没有空的子节点的情况。代码:/* On a hill is a tr

Tuesday 812

【Codeforces 675D】Tree Construction

【链接】 我是链接,点我呀:) 【题意】 依次序将数字插入到排序二叉树当中 问你每个数字它的父亲节点上的数字是啥 【题解】 按次序处理每一个数字 对于数字x 找到最小的大于x的数字所在的位置i 显然,x要放在这个x的左子树里面 所以如果x的左子树为空那么直接放上去就好 否则,左子树不为空的话,对于i的左儿子,从这个左儿子开始,一直往右儿子方向往下走 即未插入x之前,最大的...

weixin_30680385的博客 90

codeforces-675D Tree Construction

大致题意:输入n个不相同的数,依次插入bst中,输出最后每个数对应节点的父亲思路一:bst的中序遍历是有序的,所以每一棵子树对应有序序列的一个区间。先将原序列排序,按插入顺序取没有处理的节点,找到它在有序序列里的位置p,假定它的父亲所表示子树的范围是[l,r],那么[l,p-1]和[p+1,r]分别成为p的左右子树,[l,p-1]和[p+1,r]的父亲由p的父亲更改为p。所以需要一个支持区间修改的数

^_^ 579

CodeForces - 675D Tree Construction (set&数据结构)

CodeForces - 675D Tree Construction Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description During the programming c

yanghui07216的博客 542

Codeforces 675D Tree Construction (splay)

题意往一个根为a[0]的二叉搜索树里面插数,每插一个数就输出他的父节点。思路根据二叉搜索树的性质,我们插进去一个数,他的父节点肯定是比他小的最大的和比他大的最小的数里面的两个,然后这两个节点找最深的那个就是他的父节点,我们可以给这些节点设置一个时间戳就能判断先后顺序了。 在找那两个节点的时候我是直接用的splay找的,实际上我们可以直接用两个set一个储存负数一个储存正数然后两个lower_bou

Winterfell30' Blog 933

codeforces 675D Tree Construction 数据结构

题目链接:http://www.codeforces.com/contest/675/problem/D 题意: 依次给出每个节点的值,要求最终得到一颗二叉排序树,第一个节点是根,求每个节点的父节点。 思路: 对于每个插入的节点,要么成为比它小的最大的节点右儿子,要么成为比它大的最小节点的左儿子。 把每个节点依次放入set里面用lower_bound查找就可以了。 顺便复习了一下set...

weixin_30569033的博客 102

CodeForces 675D Tree Construction

递归,$RMQ$。 因为$n$较大,可以采用递归建树的策略。 对每一个点标一个$id$。然后按照$v$从小到大排序,每一段$[L,R]$的根节点就是$id$最小的那个。 因为二叉搜索树可能是一条链,所以不能暴力找$id$最小的,需要用线段树或者$RMQ$预处理快速寻找。 #pragma comment(linker, "/STACK:1024000000,1024000000") #...

weixin_34327223的博客 121
上一篇: CodeForces - 675C Money Transfers 思维
下一篇: 【Codeforces Round 354 (Div 2)B】【简单模拟】Pyramid of Glasses
sega_handsome
博客等级 码龄10年 7粉丝 164原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值