ACM-ICPC 2015 Changchun Preliminary Contest

 

H. Elven Postman

Elves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not something to be taken lightly. Also, they live on trees. However, there is something about them you may not know. Although delivering stuffs through magical teleportation is extremely convenient (much like emails). They still sometimes prefer other more “traditional” methods.

So, as a elven postman, it is crucial to understand how to deliver the mail to the correct room of the tree. The elven tree always branches into no more than two paths upon intersection, either in the east direction or the west. It coincidentally looks awfully like a binary tree we human computer scientist know. Not only that, when numbering the rooms, they always number the room number from the east-most position to the west. For rooms in the east are usually more preferable and more expensive due to they having the privilege to see the sunrise, which matters a lot in elven culture.

Anyways, the elves usually wrote down all the rooms in a sequence at the root of the tree so that the postman may know how to deliver the mail. The sequence is written as follows, it will go straight to visit the east-most room and write down every room it encountered along the way. After the first room is reached, it will then go to the next unvisited east-most room, writing down every unvisited room on the way as well until all rooms are visited.

Your task is to determine how to reach a certain room given the sequence written on the root.

For instance, the sequence 2,\ 1,\ 4,\ 32, 1, 4, 3 would be written on the root of the following tree.

Input Format

First you are given an integer T(T\le 10)T(T≤10) indicating the number of test cases.

For each test case, there is a number n(n\le 1000)n(n≤1000) on a line representing the number of rooms in this tree. nnintegers representing the sequence written at the root follow, respectively a_1,\ ...,\ a_na1​, ..., an​ where a_1,\ ...,\ a_n\in \{1,\ ...,\ n\}a1​, ..., an​∈{1, ..., n}.

On the next line, there is a number qq representing the number of mails to be sent.

After that, there will be qq integers x_1,\ ...,\ x_qx1​, ..., xq​ indicating the destination room number of each mail.

Output Format

For each query, output a sequence of move (EE or WW) the postman needs to make to deliver the mail. For that EEmeans that the postman should move up the eastern branch and WW the western one. If the destination is on the root, just output a blank line would suffice.

Note that for simplicity, we assume the postman always starts from the root regardless of the room he had just visited.

样例输入

2
4
2 1 4 3
3
1 2 3
6
6 5 4 3 2 1
1
1

样例输出

E

WE
EEEEE

题目来源

ACM-ICPC 2015 Changchun Preliminary Contest

题意:倒过来看是一个二叉排序树,在查找过程中,往树的左边走是W,往树的右边走是E

所以根据题目输入的数据,建树然后再查找就好了,在查找的过程中输出W或者E,当查找的元素为树根的时候,就直接输出一个空就可以了。

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int n,q;
int a,b;
typedef struct node
{
 int d;
 struct node *left,*right;
}BiNode,*BiTree;
BiTree  build(BiTree &T,int key)
{
	if(T==NULL)
	{
		T=(BiTree)malloc(sizeof(BiNode));
		T->d=key;
		T->left=NULL;
		T->right=NULL;
	}
	else
	{
		if(T->d<key)
		T->left=build(T->left,key);
        else
		T->right=build(T->right,key); 
	}
	return T;
}
void find(BiTree &T,int key)
{
  if(T)
  {
  	if(T->d==key)
  	{
  	   printf("\n")	;
  	   return ;
	}
	else
	{
		if(T->d<key)
		{
			printf("W");
			find(T->left,key);
		}
		else
		{
			printf("E");	
		    find(T->right,key);
		}
	}
  }
}
int main()
{
  int t;
  scanf("%d",&t);
  while(t--)
  {
  	scanf("%d",&n);
  	BiTree T;
  	 T=NULL;
  	for(int i=0;i<n;i++)
  	{
  	  scanf("%d",&a);
	  T=build(T,a);	
	}
	 scanf("%d",&q);
	 for(int i=0;i<q;i++)
	 {
	 	scanf("%d",&b);
	 	if(T==NULL && T->d==b)
	 	 printf(" \n");
	 	else
	 	 find(T,b);
	 }
  }	
  return 0;
}

注意:

1.查找过程中,注意段错误,就是有不合法的指针,我在这个地方出现的错误是没有判断树为空时这一种情况

2.建树的过程要规范,结构体不要随意改变,每一个建树都用这一模板就好了,随意改动,写代码的时候,自己把自己写糊涂了。

3.要熟悉树的知识,再做这个题目的时候,老师出现段错误,总是改不出来,起始就是查找的时候出现错误,没有对树为空的时候这一情况进行判断,所以又翻看了之前的代码。

 

G. The Water Problem

In Land waterless, water is a very limited resource. People always fight for the biggest source of water.

Given a sequence of water sources with a_1,\ a_2,\ a_3,\ ...,\ a_na1​, a2​, a3​, ..., an​ representing the size of the water source.

Given a set of queries each containing 22 integers ll and rr, please find out the biggest water source between a_lal​and a_rar​.

Input Format

First you are given an integer T(T\le 10)T(T≤10) indicating the number of test cases.

For each test case, there is a number n(0 \le n \le 1000)n(0≤n≤1000) on a line representing the number of water sources.

nn integers follow, respectively a_1,\ a_2,\ a_3,\ ...,\ a_na1​, a2​, a3​, ..., an​, and each integer is in \{1,\ ...,\ 10^6\}{1, ..., 106}.

On the next line, there is a number q(0 \le q \le 1000)q(0≤q≤1000) representing the number of queries.

After that, there will be qq lines with two integers ll and r(1 \le l \le r \le n)r(1≤l≤r≤n) indicating the range of which you should find out the biggest water source.

Output Format

For each query, output an integer representing the size of the biggest water source.

样例输入

3
1
100
1
1 1
5
1 2 3 4 5
5
1 2
1 3
2 4
3 4
3 5
3
1 999999 1
4
1 1
1 2
2 3
3 3

样例输出

100
2
3
4
4
5
1
999999
999999
1

题目来源

ACM-ICPC 2015 Changchun Preliminary Contest

题意:再输入的数据中,查找区间内最大值,是一道很简单的题目。

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
const int maxn =1e3+10;
int t,n;
int a[maxn];
int k,l,r;
int main()
{
	while(scanf("%d",&t)!=EOF)
	{
		while(t--)
		{
			scanf("%d",&n);
			for(int i=1;i<=n;i++)
		   {
			scanf("%d",&a[i]);
		   }
	    	scanf("%d",&k);
		  for(int i=0;i<k;i++)
		 {
			scanf("%d%d",&l,&r);
			int max=a[l];
			for(int j=l+1;j<=r;j++)
			{
				if(a[j]>max)
				{
					max=a[j];
				}
			}
			printf("%d\n",max);
		}
		}
		
	}
	return 0;
} 

注意:

1.看清楚有一个变量t,来控制输入多少组数据,简单题敲完代码,也要快中求稳。

《VMware vSAN 超融合技术规划与部署》课程共分为“上集”和“下集”两部分,本套视频为“下集”部分,接续“上集”知识,是vSAN技术进阶推荐课程。  《VMware vSAN 超融合技术规划与部署》“下集”部分具体课程章节如下。  第1章 《使用延伸群集将数据存储扩展到两个站点》主要内容本章主要讲解了vSAN延伸群集的相关理论及构建vSAN延伸群集的方法。通过本章学习,您可以掌握延伸群集的设计注意事项和推荐做法;掌握使用快速入门功能配置延伸群集的方法;掌握手动配置延伸群集的方法;掌握将延伸群集更改为标准群集的方法。  第2章 《vSAN延伸群集策略》主要内容本章主要讲解了vSAN延伸群集中的虚拟机存储策略。通过本章学习,您可以理解允许的故障数主要级别 (PFTT)含意;理解允许的故障数辅助级别 (SFTT)含意;通过试验进一步理解PFTT和SFTT含意;掌握将VM放置在首xuan站点和辅助站点操作过程。  第3章 《管理 vSAN 群集中的故障域》主要内容本章主要讲解了vSAN群集中的故障域相关理论和实践知识。通过本章学习,您可以了解故障域的设计思想;掌握在 vSAN 群集中创建新的故障域的操作方法;掌握将主机移出故障域的操作方法;掌握将主机移至选定的故障域的操作方法;掌握重命名故障域的操作方法;掌握移除选定的故障域的操作方法。  第4章 《管理 vSAN 群集》主要内容本章主要讲解了管理vSAN群集相关知识。通过本章学习,您可以理解什么是维护模式;掌握使用维护模式的操作方法;掌握将混合 vSAN 群集迁移到全闪存群集操作方法;掌握关闭 vSAN 群集电源的方法。  第5章 《使用 vSAN iSCSI 目标服务》主要内容本章主要讲解了在vSAN环境中配置iSCSI目标服务,以把vSAN数据存储提供给外部用户使用。通过本章学习,您可以掌握vSAN iSCSI 目标服务的设计思想;学会创建vSAN iSCSI 目标服务;学会使用客户端连接vSAN iSCSI 目标服务;掌握vSAN iSCSI 目标服务的使用方法。  第6章 《vSAN 群集中的设备管理》主要内容本章主要讲解了vSAN 群集中的设备(缓存盘和容量盘)管理。通过本章学习,您可以学会将设备添加到磁盘组的操作方法;学会从 vSAN 移除磁盘组或设备的操作方法;学会重新创建磁盘组的操作方法;学会使用定位符 LED的操作方法;学会将设备标记为闪存的操作方法;学会将设备标记为 HDD的操作方法;学会添加容量设备的操作方法;学会从设备移除分区的操作方法。  第7章 《提高 vSAN 群集中的空间效率》主要内容本章主要讲解了提高 vSAN 群集中的空间效率相关知识。通过本章学习,您可以了解vSAN 空间效率理论知识;掌握使用去重和压缩的操作方法;了解RAID 5 或 RAID 6 删除编码;了解RAID 5 或 RAID 6 设计注意事项。  第8章 《vSAN监控》主要内容本章主要讲解了vSAN监控相关知识。通过本章学习,您可以掌握监控 vSAN 群集的操作方法;掌握监控 vSAN 运行状况的操作方法;掌握监控 vSAN 性能的操作方法。  VMware vSAN 6.7 超融合技术规划与部署(上集):https://edu.csdn.net/course/detail/35188VMware vSAN 6.7 超融合技术规划与部署(下集):https://edu.csdn.net/course/detail/35191
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值