多校 Babelfish
题目链接:http://acm.hust.edu.cn/vjudge/contest/124435#problem/A
密码:acm

Sample Input
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay Sample Output
cat
eh
loops
分析:存和用的时候时要注意滴。gets,空格,len=0结束,空间,时间。
先空间超限再时间超限,唉~
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include<queue>
#include<math.h>
using namespace std; #define N 250
#define maxn 115200 char str[N],s[N],ss[N]; struct node
{
char s1[N],s2[N];///这里开太大了要空间超限的
} p[maxn]; int cmp(node e,node f)
{
return strcmp(e.s2,f.s2)<;
}
int main()
{
int i,j=,k; while(gets(ss))
{
int a=,b=;
int len=strlen(ss);
if(len==)
break;///这样就可以完美结束了 for(i=; ss[i]; i++)
if(ss[i]==' ')
{
k=i;
break;
} for(i=; i<k; i++)
p[j].s1[a++]=ss[i];
for(i=k+; i<len; i++)
p[j].s2[b++]=ss[i];
j++;
}
sort(p,p+j,cmp); while(scanf("%s", s) != EOF)
{
int w=;
int l=,r=j-;
///二分了,就不会时间超限啦
while(l<=r)
{
int mid=(r+l)/;
if(strcmp(s,p[mid].s2)==)
{
w=;
printf("%s\n", p[mid].s1);
break;
}
else if(strcmp(p[mid].s2,s)>)
r=mid-;
else
l=mid+;
}
if(w==)
printf("eh\n");
}
return ;
}
多校 Babelfish的更多相关文章
- 【开源毕设】一款精美的家校互动APP分享——爱吖校推 [你关注的,我们才推](持续开源更新3)附高效动态压缩Bitmap
一.写在前面 爱吖校推如同它的名字一样,是一款校园类信息推送交流平台,这么多的家校互动类软件,你选择了我,这是我的幸运.从第一次在博客园上写博客到现在,我一次一次地提高博文的质量和代码的可读性,都是为 ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- NTP校时设置
一.Windows Server 2008 – Time Server 前言: 国家时间与频率标准实验室 && NTP服务器 也可以忽略1~6 直接跳7 如果已改过机码请使用 1 ...
- 2016暑假多校联合---Rikka with Sequence (线段树)
2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...
- 2016暑假多校联合---Windows 10
2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...
- 2016暑假多校联合---Substring(后缀数组)
2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...
- 2016暑假多校联合---To My Girlfriend
2016暑假多校联合---To My Girlfriend Problem Description Dear Guo I never forget the moment I met with you. ...
- 2016暑假多校联合---A Simple Chess
2016暑假多校联合---A Simple Chess Problem Description There is a n×m board, a chess want to go to the po ...
- HDU 5792---2016暑假多校联合---World is Exploding
2016暑假多校联合---World is Exploding Problem Description Given a sequence A with length n,count how many ...
随机推荐
- java代码块 静态、非静态
Java虚拟机的内存分区:Java栈.堆.方法区.本地方法栈.PC寄存器.还有一个常量池的概念,虚拟机会为每种类型分配一个常量池,而不是实例. 例如有一个类有很多子类,那么在父类定义的final变量, ...
- html5游戏开发框架之lufylegend开源库件学习记录
下载地址http://lufylegend.com/lufylegend 引用 <script type="text/javascript" src="../luf ...
- for计算100以内的奇数和
#include "stdio.h" void main() { //for计算100以内的奇数和 步长为1,continue实现 ; ;i<=;i++) { ==) { c ...
- 10- python 网络爬虫分析
Python 网络爬虫简单分析 import urllib2 response = urllib2.urlopen("http://www.baidu.com") print re ...
- log4j配置详解[http://www.iteye.com/topic/378077]
log4j是一个非常强大的log记录软件,下面我们就来看看在项目中如何使log4j. 首先当然是得到log4j的jar档,推荐使用1.2.X版,下载地址: http://logging.apache. ...
- # Linux Whois3获取 运营商信息
Linux Whois3获取 运营商信息 APNIC是管理亚太地区IP地址分配的机构,它有着丰富准确的IP地址分配库,同时这些信息也是对外公开的,并提供了一个查询工具,下面就让我们看看如何在Linux ...
- js cookie 记住用户名密码
function saveUserInfo(){ if($("#remember").attr('checked')=="checked"){ var user ...
- XBOX360 硬盘玩游戏
首先PC端需要到flashFXP这个软件,因为级别不够上传不了就发个下载网站各位自己下一下吧.http://www.oyksoft.com/soft/14875.html#oyksoftdown 好了 ...
- HTTP 返回状态值详解
当用户点击或搜索引擎向网站服务器发出浏览请求时,服务器将返回Http Header Http头信息状态码,常见几种如下: 1.Http/1.1 200 OK 访问正常 表示成功访问,为网站可正常访问 ...
- 第十四节,基本数据类型,列表list
创建列表 #!/usr/bin/env python # -*- coding:utf-8 -*- a = ['alex', 'seven', 'eric'] #或 a = list(['alex' ...