F - Babelfish解题报告(黄杰)

vivado生成及调用自定义IP的方法 开发环境:vivado 2018.2 1.将整个工程封装为自定义IP 将整个工程封装为自定义IP主要有以下步骤: 步骤1.选中工程中的top模块。点击Tools ------> Create and Package New IP,如图1所示 图1 步骤2.弹出界面后,点击next至图2界面,选择Package your current project,然后继续点击next 图2 步骤3.选择生成的IP路径,如图3所示。这个路径就是后续添加该IP的路径 图3 步骤4.继续点击next,然后选择fi 阅读详情

F - Babelfish
Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

Hint

Huge input and output,scanf and printf are recommended.

题目大意:给你一本字典,左边是英文,右边是火星文(这是我这么说的。。),然后输入火星文,是否能找到相应的翻译,有则输出翻译,无则输出eh。
题目链接:http://poj.org/problem?id=2503
方法:数组排序及二分查找
思路:其实这道题我也是了解了bsearch函数与qsort函数后做的,一开始还真没想出来,如果有不懂这两个函数的,可以看我上一篇介绍再看这道题,会更方便理解,过程大致就是先存入字典,我定义了一个结构体,这样将英文和火星文联系在一起,防止后面排序的时候又要在替换英文的位置,比较麻烦,直接排序结构体就行,这样写比较函数时可以通过比较结构体中的火星文来排,这样结构体中的英文也随之移动,比较方便。输入就是要遇到一行空格字典结束,然后在进行输入火星文判断是否有翻译,这可以用bsearch来寻找是否结构体数组有相同的火星文,从而实现算法。
算法实现:


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct dic//定义结构体,使翻译与原语联系在一起。
{
	char eng[11];//翻译。
	char fn[11];//原语。
};
struct dic a[1000001]; 

int fcmp(const void * a,const void *b)// 定义qsort比较函数
{
    return strcmp(((dic*)a)->fn, ((dic*)b)->fn);
}

int cmp(const void* a, const void* b)// 定义bsearch比较函数 
{
    return strcmp((char*)a, ((dic*)b)->fn);
}

int main()
{
	int i,j,k,sum,sign,len;
	char str[30];
	struct dic *p;
	sum=0;
	sign=0;
	while(gets(str))
	{
		len=strlen(str);
		if(len==0)//读取的为空行则字典输入完毕。
			break;
		else//否则分段存储翻译与原语。
		{
			for(i=0;i<len;i++)
			{
				if(str[i]==' ')
					break;
				a[sum].eng[i]=str[i];
			}
			a[sum].eng[i]='\0';//记的字符串最后一位为'\0'。
			for(j=i+1,k=0;j<len;j++,k++)
				a[sum].fn[k]=str[j];
			a[sum].fn[k]='\0';
			sum++;
		}
	}
	qsort(a,sum,sizeof(dic),fcmp);//将数组升序排列。
	while(gets(str))
	{
		p=(dic*)bsearch(str,a,sum,sizeof(dic),cmp);//进行二分查找,返回结构体类型指针。
		if(p)
			puts(p->eng);
		else
			puts("eh");
	}
	return 0;
}




OpenCV快速入门:绘制图形、图像金字塔和感兴趣区域 OpenCV是一个强大的计算机视觉库,广泛应用于图像处理、计算机视觉和机器学习等领域。本文将介绍OpenCV中的一些基础功能,包括如何绘制图形、创建图像金字塔以及如何处理感兴趣区域(ROI)。 阅读详情

相关推荐

关于 MCU 芯片外围电路的快速入门介绍

MCU 外围电路的核心是“围绕 MCU 需求,搭建稳定、匹配的外部支撑”,入门阶段无需掌握复杂设计,只需先吃透供电、复位、时钟、IO 驱动、基础通信这五大模块,再逐步扩展存储、显示、传感器等进阶功能。实践中多调试、多参考成熟方案,是快速掌握外围电路设计的关键。码字不易,若觉得本文对你有用,欢迎,相关技术热点时时看🔥🔥🔥​​​…

JiaWen的博客 1642

poj 2503 Babelfish——字典映射

Babelfish Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. Input Input consists of up to 100,000 dictionary

five_east_west的博客 484

模拟量传输4-20ma电流

大家可能会非常熟悉RS232,RS485,CAN等工业上常用的总线,他们都是传输数字信号的方式。那么,我们用什么方式来传输模拟信号呢?工业上普遍需要测量各类非电物理量,例如温度、压力、速度、角度等,这些都需要转换成模拟量电信号才能传输到几百米外的控制室或显示设备上。工业上最广泛采用的是用4~20mA电流来传输模拟量。 采用电流信号的原因是不容易受干扰,因为工业现场的噪声电压的幅度可能达到数V,但是噪声的功率很弱,所以噪声电流通常小于nA级别,因此给4-20mA传输带来的误差非常小;电流源内阻趋于无穷.

tangdongming的博客 1万+

POJ 2503 Babelfish(map)

Babelfish 题目传送门~ Time Limit:3000MS Memory Limit:65536K Total Submissions:56564 Accepted:23224 Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. F...

深秋无痕 589

RK3588多路MIPI摄像头采集与WiFi低延迟传输实战指南

本文详细介绍了基于RK3588平台实现多路MIPI摄像头同步采集并通过WiFi进行低延迟传输的完整实战方案。文章深入剖析了从V4L2驱动配置、多线程采集、环形缓冲区设计到UDP网络传输优化的核心技术,旨在帮助开发者在工业检测、智能安防等场景下构建高并发、高实时性的视频流系统,实现端到端延迟控制在100毫秒以内的目标。

tensor9flow的博客 786

105. replace( )函数

【目录】

weixin_63986098的博客 1万+

[解题报告]POJ_2503 字典树,MAP

题目很容易理解,就是每个字符串对应一个foreign字符串,然后给出foreign字符串,进行翻译 因为一开始没有学过字典树,很自然的就想到MAP了,水过之后,看了一下discuss,发现这一题的做法很多,可以用二分+查找,字典树,HASH等等,因为以前没有学习过字典树,就学习并试着写了一下,一次AC了..心情大好..关于字典树的学习帖子我发在前一篇了,是转载的~  字典树写法:

飞熊入梦 1229

024、反激变换器的短路保护设计

本文详细探讨了反激变换器短路保护的设计要点与实践经验。作者通过实际案例分析了短路时反激拓扑的电流特性,指出初级峰值电流限制是最基础的保护手段,但需配合打嗝模式使用。文章重点剖析了打嗝模式设计的三个关键陷阱:频率设定、退出条件和软启动衔接。同时强调次级侧辅助保护、变压器参数优化、环路响应协调的重要性,并比较了自恢复与锁死方案的适用场景。最后提出实测验证的四个关键点和设计经验:不盲信芯片手册、保护电路独立设计、充分留有余量、进行破坏性测试。全文以工程实践为导向,为反激电源的可靠短路保护提供了系统性解决方案。

Jack010169的博客 237

POJ 2503 Babelfish

题目链接:http://poj.org/problem?id=2503 题意:给一个词典,格式为单词x对应单词y,现在输入一些单词y,输出各自对应的单词x。 思路:建一棵trie树,在每个单词的结尾字母节点处附上单词y。然后查找的时候直接输出结尾字母节点的单词即可。 或者也可以用map水一下。 trie树代码 #include #include #incl

DS-K的博客 497

基于深度学习的图像识别技术在农业领域中的应用

是识别"病害种类"还是"病害严重度分级"?前者是分类,后者常需分割或分级回归。是叶片级(离体叶片图像)、植株级(田间单株)、地块级(无人机俯拍)?视角不同,模型差异巨大。实时无人机巡检可能要求 < 50 ms/帧(Jetson Orin),而离线测报可接受秒级推理。类别标签、结构化 JSON、GIS 图斑、报警事件?

AI天才研究院 2164

Arcgis中的模型构建器技术之按属性批量建库并对应输出

好久没更新了,之前我们已经介绍过四至点提取模型,前两天有同事问怎么样按属性批量建数据库并对应输出相关图斑。比如将一个县的永农数据按乡镇建立数据库并将对应乡镇的永农数据输出到相应的数据库里。今天就介绍一下相关的模型构建过程。

weixin_44671081的博客 517

ACM: hash题 poj 2503

Babelfish Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understan

smile_benson 969

android13删除录屏权限提示框-去除录屏提示

在Android 13中,当应用请求屏幕录制权限时,系统会弹出一个权限提示框,要求用户明确授权。这个提示框是为了增强用户隐私保护,让用户知道有应用尝试录制屏幕。但是,在某些情况下,开发者可能希望避免显示这个提示框,以提供更流畅的用户体验。本文将介绍如何在Android 13中删除录屏权限提示框。

zhutoubenben的专栏 1880

Babelfish(c语言)

题目描述 You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. 输入 Input consists of up to 100,000 dictionary entries, followed b

qq_63683485的博客 2373

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

POJ-2503 Babelfish 解题报告

Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

岁月流风、、 1472

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Babelfish

Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. ...

raptor 2006

ssm框架搭建

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

poj 2503 Babelfish(字典树或着STL)

Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 35828   Accepted: 15320 Description You have just moved from Waterloo to a big city. The people her

舒哥的blog 1213

ZCMU--1787: Problem C: Babelfish

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.Input consists of up to 100,000 dictionary entries, followed by a blank

小小小Why的博客 466

分治总结2

问题 B: 【分治】Babelfish 题目: You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you underst...

Spidy_harker的博客 1286

POJ 2503 Babelfish(字典树模板题)

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. Input Input ...

kuronekonano的博客 367

1030. 方言翻译

样例 input: dog ogday cat atcay pig igpay froot ootfray loops oopslay atcay ittenkay oopslay output: cat eh loops 思路: 这里用的是最一般的hash写法,效率相对低 tips: 1.gets在处理时遇到回车或者文件末尾才停止,所以需要把两个字符串分开 同时也需要注意s的数组要开的大一点不然就会导致数组越界 2.gets()的返回值时NULL 代码: #include <cstdio> .

Rachelhello123的博客 347

Poj 2503 Babelfish

Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 34221   Accepted: 14678 Description You have just moved from Waterloo to a big city. The people her

u013082590的专栏 607

POJ 2503 Babelfish(二分查找)

Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand

SHUI 1010

fjnu 1548 Babelfish

DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

异リ度ュ空ウ間(镜像站) 1052

F - Babelfish解题报告

Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

谢庆皇的专栏 615

北大ACM2503——Babelfish~~字典树的应用

题目的意思是:给你几个字符串对str1,str2。输入完毕后有一个空行,然后是询问的输入,每行一个字符串,如果该字符串与str2相同,则输出str1,否则输出“eh”。 这题字符串对达到100000,询问的也达到了100000个,所以,普通的方法必定超时。所以需要建立字典树。 这题还有一个比较麻烦的就是输入。如何控制那一个空行之后的询问输入,这是关键。 简单的字典树的应用。 下面是AC的代

XD 1104
上一篇: D - Eqs解题报告(黄杰)
下一篇: I - Expanding Rods解题报告(黄杰)
CSUST_ACM
博客等级 码龄15年 42粉丝 127原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值