Trees on the level

从CT到3D分割:手把手复现H-DenseUNet肝脏肿瘤分割模型(PyTorch版) 本文详细介绍了如何使用PyTorch复现H-DenseUNet模型进行肝脏肿瘤的3D分割,从CT数据预处理到模型架构实现,再到训练策略与性能评估。通过结合2D与3D分支的混合特征融合技术,H-DenseUNet在LiTS数据集中展现了卓越的分割性能,特别适合医学影像分析领域的应用。 阅读详情

题目描述:

Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- and octal-trees are fundamental to many algorithms in computer graphics.

This problem involves building and traversing binary trees.
Given a sequence of binary trees, you are to write a program that prints a level-order traversal of each tree. In this problem each node of a binary tree contains a positive integer and all binary trees have have fewer than 256 nodes.

In a level-order traversal of a tree, the data in all nodes at a given level are printed in left-to-right order and all nodes at level k are printed before all nodes at level k+1.

For example, a level order traversal of the tree
在这里插入图片描述
is: 5, 4, 8, 11, 13, 4, 7, 2, 1.

In this problem a binary tree is specified by a sequence of pairs (n,s) where n is the value at the node whose path from the root is given by the string s. A path is given be a sequence of L’s and R’s where L indicates a left branch and R indicates a right branch. In the tree diagrammed above, the node containing 13 is specified by (13,RL), and the node containing 2 is specified by (2,LLR). The root node is specified by (5,) where the empty string indicates the path from the root to itself. A binary tree is considered to be completely specified if every node on all root-to-node paths in the tree is given a value exactly once.

输入:

The input is a sequence of binary trees specified as described above. Each tree in a sequence consists of several pairs (n,s) as described above separated by whitespace. The last entry in each tree is (). No whitespace appears between left and right parentheses.

All nodes contain a positive integer. Every tree in the input will consist of at least one node and no more than 256 nodes. Input is terminated by end-of-file.

输出:

For each completely specified binary tree in the input file, the level order traversal of that tree should be printed. If a tree is not completely specified, i.e., some node in the tree is NOT given a value or a node is given a value more than once, then the string ``not complete’’ should be printed

样例输入:

(11,LL) (7,LLL) (8,R)
(5,) (4,L) (13,RL) (2,LLR) (1,RRR) (4,RR) ()
(3,L) (4,R) ()

样例输出:

5 4 8 11 13 4 7 2 1
not complete

作为一只蒟蒻的我,看到判断是否是树,总是莫名其妙想到的并查集???
但是仔细阅读,发现,,虽然也不是不能写,就是,,太麻烦啦,估计要好长好长
巨懒的我觉定看一下别人的思路,顺便学习一下
下面是总结之后的代码

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map> 
using namespace std;
struct node{
	int x,y;
	string s;
}edge[1010];
map<string,int> feng;
bool cmp(node a,node b)
{
	if(a.y==b.y)return a.s<b.s;
	else return a.y<b.y;
}
int main()
{
	string a;
	int n=0,flag=0;
	while(cin>>a)
	{
		if(a=="()")
		{
			sort(edge,edge+n,cmp);
			if(flag==1||edge[0].y!=0)
			{
				printf("not complete\n");
			}
			else
			{
				for(int i=0;i<n;i++)
				{
					if(edge[i].y>0)
					{
						string ss="";
						int len=edge[i].s.length();
						for(int j=0;j<len-1;j++)
						{
							ss+=edge[i].s[j];
						}
						if(feng[ss]!=1)
						{
							flag=1;
							break;
						}
					}
				}
				if(flag==1)printf("not complete\n");
				else
				{
					for(int i=0;i<n;i++)
					{
						if(i!=0)printf(" ");
						printf("%d",edge[i].x);
					}
					printf("\n");
				 } 
			}
			n=flag=0;
			feng.clear();
		}
		else
		{
			int i;
			int num=0;
			for(i=1;i<a.length();i++)
			{
				if(a[i]==',')break;
				else
				{
					num=num*10+a[i]-'0';
				}
			}
			edge[n].x=num;
			edge[n].s.clear();
			num=0;
			for(i=i+1;i<a.length();i++)
			{
				if(a[i]==')')break;
				num++;
				edge[n].s+=a[i];
			}
			feng[edge[n].s]++;
			if(feng[edge[n].s]>1)flag=1;
			edge[n].y=num;
			n++;
		}
	} 
	return 0;
}
【代码超详解】UVA 122 Trees on the Level(二叉树、BFS) 紫书 第六章 例题 6-7 Trees on the level, Duke 1993, UVa 122 第一回手写二叉树,今天就为这道题磕了一整天才过了样例,不过好在一提交就AC了。 一、题目描述 输入包含多组数据。每组数据给出一系列有序对 (v, s) (单个空格隔开两个对)代表二叉树的某个节点的值,你的任务是从根到叶输出各个节点的值 v 。同一层输出顺序自然是从左到右。最多有 256 个节点... 阅读详情

相关推荐

从零搭建openEuler ARM64开发测试环境:手把手教你用libvirt+KVM配置虚拟机(含VNC远程安装)

本文详细介绍了如何在ARM64平台上从零搭建openEuler开发测试环境,涵盖libvirt和KVM配置虚拟机的完整流程,包括环境准备、存储配置、网络优化、XML配置详解以及VNC远程安装。特别针对华为欧拉(openEuler)系统进行了优化,帮助开发者快速构建高效的ARM架构虚拟化环境。

weixin_30545945的博客 587

UVA122

Background 背景 Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines' CM-5 are based on fat trees. Quad- and octal-trees ar

crazychen的专栏 1178

Python脚本自动化芯片设计?PyAether实战教程带你玩转EDA

本文通过PyAether实战教程,详细介绍了如何利用Python脚本实现芯片设计自动化。内容涵盖环境搭建、核心对象模型解析,并重点演示了原理图自动生成、参数化单元创建及设计验证流程集成,帮助EDA工程师从重复性手动操作中解放,显著提升设计效率与一致性。

e4f5g6h的博客 1318

【可运行,刘汝佳代码】Trees on the level UVA - 122

立志用最少的代码做最高效的表达 Trees are fundamental in many branches of computer science (Pun definitely intended). Current stateof-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- and octal-trees are fundamental to many algorit

weixin_43899069的博客 963

Gitlab+Jenkins+Docker+Harbor+K8s+Rancher集群搭建CICD平台

本文以诺依项目为例详细记录了Kubernetes集群的部署过程以及配套DevOps环境的搭建。主要内容包括:1) 配置8个节点的软硬件环境;2) 基础环境准备(网络、防火墙、Docker等);3) 三节点Kubernetes集群部署;4) GitLab代码仓库安装;5) Harbor私有镜像仓库搭建;6) Jenkins持续集成工具配置;7) 基于若依项目的CI/CD实践;8) Rancher集群管理工具部署。

hickman2023的博客 1205

XC95144XL-10TQG144I Xilinx XC9500XL 高性能 CPLD

XC95144XL-10TQG144I 属于 Xilinx 的 XC9500XL 高性能 CPLD 家族,是一颗面向 3.3V 低电压系统的可编程逻辑器件。该器件以小封装、高速响应和良好的系统兼容性为设计目标,常用作系统控制/ glue-logic、I/O 缓冲、状态机、总线桥接与接口协议前端等场景中的可重编程逻辑单元。产品支持现场(in-system)编程与 IEEE-1149.1 JTAG 边界扫描,能在系统板上直接更新逻辑。

2403_90082736的博客 1060

Trees on the level HDU - 1622(二叉树)

Problem Description Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- and octal-tree...

我の名字 454

Nestjs框架: 集成 Prisma

NestJS官方文档提供了两种数据库相关的内容:Techniques下的数据库板块和Recipes下的具体数据库集成方案。本文以Prisma为例,演示了如何集成Prisma到NestJS项目中。首先创建NestJS项目并安装Prisma,配置MySQL数据库连接。通过Prisma CLI初始化项目、定义数据模型并生成迁移文件。接着创建Prisma模块和服务,配置Prisma客户端连接数据库。最后在控制器中注入PrismaService实现数据查询。整个过程包含了Docker启动MySQL、Prisma模型定

Wang的专栏 1295

例题6-7 树的层次遍历

Trees on the level Trees are fundamental in many branches of computer science (Pun definitely intended). Current stateof-theart parallel computers such as Thinking Machines’ CM-5 are based on fat...

weixin_30809173的博客 356

[网络安全自学篇] 七十三.WannaCry勒索病毒复现及分析(四)蠕虫传播机制全网源码详细解读

这是作者网络安全自学教程系列,主要是关于安全工具和实践操作的在线笔记,特分享出来与博友们学习,希望您喜欢,一起进步。前文分享了逆向分析OllyDbg动态调试工具的基本用法,包括界面介绍、常用快捷键和TraceMe案例分析。这篇文章将继续详细讲解WannaCry蠕虫的传播机制,带领大家详细阅读源代码,分享WannaCry勒索病毒是如何传播感染的。作者分析该病毒一个月,一方面觉得自己技术菜,另一方面深知系统安全需要坚持,继续加油。希望文章对您有所帮助~

杨秀璋的专栏 1万+

ADBC 全面解析:ABAP 开发者玩转 Native SQL 的实战指南

本文介绍了 SAP ABAP 中的 ADBC(ABAP Database Connectivity)技术,它是一种基于 ABAP 面向对象的类库,用于访问 Native SQL 接口。与 Open SQL 和 EXEC SQL 相比,ADBC 具有以下优势:支持特定数据库语法、可访问二级数据库连接、执行多种 SQL 操作且语法更 ABAP 化。文章通过示例展示了 ADBC 的基本用法,包括创建语句对象、执行查询和处理结果集。建议在需要数据库特有功能或二级连接时优先使用 ADBC,同时提供封装类来简化调用。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 309

uva122 trees on the level

看不下去,找点简单的,再回来写

Dosth_Magic 625

独立游戏之路:Tap篇 -- 个人开发者上架TapTap步骤和注意事项

作为一名游戏开发者,将自己的独立游戏上架到 TapTap 平台是一个不错的选择。TapTap 是一个拥有大量用户的游戏社区平台,上架游戏可以让更多的玩家发现和体验你的游戏。TapTap 是一个游戏社区平台,用户可以在平台上下载和分享游戏。TapTap 拥有大量的用户,并且用户活跃度高,这为独立游戏开发者提供了一个很好的展示和推广平台。进入TapTap开发者服务后台。

陈言必行 -- Unity游戏开发领域优质博主 6420

(二叉树建树 先序遍历)UVA_122 Trees on the level

UVA_122 Trees on the level题意让我们构建一棵树,给出每一个节点是从根节点怎么走才能走到. 比如(11,LL)就是根节点的左子树的左子节点的位置权值为11.然后让给出这棵树的先序遍历结果. 如果出现下列情况,输出”not complete” 重复赋值 没有根节点 有节点没有被赋值 给出超过一个节点 解决这个题的输入比较坑啊,刚上来感觉解决不了…

ZhangYang 410

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Camera2Demo

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

UVA-122(Trees on the level)

Trees on the level 题目链接: https://vjudge.net/problem/UVA-122 题目意思: 给你一些(,)让你建立一棵树,直到输入()结束建树,然后判断树是否完整,如果没有结点未赋值或者被赋值两次,就按层次遍历输出树,否则输出not complete 代码: #include <algorithm> #include <m...

weixin_30278237的博客 91

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

UVA.122 Trees on the level(二叉树 BFS)

UVA.122 Trees on the level(二叉树 BFS)题意分析给出节点的关系,按照层序遍历一次输出节点的值,若树不完整,则输出not complete代码总览#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <vector> #

Pengwill's Blog 361

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Trees on the level UVA - 122

Trees on the level UVA - 122 紫书6.3.2 二叉树的层次遍历 采用动态结构创建二叉树 #include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <queue> using namespace s...

NaNa 154

[UVA] Trees on the level

题目:https://vjudge.net/problem/UVA-122 #include<cstdio> #include<cstring> #include<vector> #include<queue> #pragma warning(disable:4996) using namespace std; const int maxn =...

weixin_37992828的博客 163

122 Trees on the level

一个二叉树的题; 看的书上和网上的结合,用一个动态结构构造一棵树,比较麻烦,但好理解 #include #include #include using namespace std; const int maxn=260; int ans[maxn];//用来装输出的数的结点值 struct Node { bool have_value;//是否被定义 int v;//结

DS00HY的小博客 274

122 - Trees on the level

Background Trees arefundamental in many branches of computer science. Current state-of-the artparallel computers such as Thinking Machines' CM-5 are based on fattrees. Quad- and octal-trees are funda

gaoxiangnumber1——Gao Xiang's Blog 483
上一篇: Fence Repair
下一篇: Elven Postman
大橘为重eleven
博客等级 码龄8年 35粉丝 103原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值