题目链接: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的更多相关文章

  1. 【开源毕设】一款精美的家校互动APP分享——爱吖校推 [你关注的,我们才推](持续开源更新3)附高效动态压缩Bitmap

    一.写在前面 爱吖校推如同它的名字一样,是一款校园类信息推送交流平台,这么多的家校互动类软件,你选择了我,这是我的幸运.从第一次在博客园上写博客到现在,我一次一次地提高博文的质量和代码的可读性,都是为 ...

  2. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  3. NTP校时设置

    一.Windows Server 2008 – Time Server 前言: 国家时间与频率标准实验室  && NTP服务器 也可以忽略1~6 直接跳7 如果已改过机码请使用 1   ...

  4. 2016暑假多校联合---Rikka with Sequence (线段树)

    2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...

  5. 2016暑假多校联合---Windows 10

    2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...

  6. 2016暑假多校联合---Substring(后缀数组)

    2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...

  7. 2016暑假多校联合---To My Girlfriend

    2016暑假多校联合---To My Girlfriend Problem Description Dear Guo I never forget the moment I met with you. ...

  8. 2016暑假多校联合---A Simple Chess

    2016暑假多校联合---A Simple Chess   Problem Description There is a n×m board, a chess want to go to the po ...

  9. HDU 5792---2016暑假多校联合---World is Exploding

    2016暑假多校联合---World is Exploding Problem Description Given a sequence A with length n,count how many ...

随机推荐

  1. Sersync同步过滤.svn文件夹

    Sersync同步过滤.svn文件夹 <filter start="true"> <exclude expression="(.*).svn(.*)&q ...

  2. git提交失败

    git push "提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支."的解决办法 本地已存在项目,需要先获取远端更新并与本地合并,再git push具体操作如下: ...

  3. 利用socket模块检查端口存活并邮件警报

    可以用来监控一些端口. import socket def check_server(addr, port): s = socket.socket() try: s.connect((addr, po ...

  4. YII2 小部件(widgets)

    小部件基本上在views中使用,在视图中可调用 yii\base\Widget::widget() 方法使用小部件. 该方法使用 配置 数组初始化小部件并返回小部件渲染后的结果. 例如如下代码插入一个 ...

  5. hdu_2110_Crisis of HDU(母函数)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2110 题意:给你N个价值和数目,求方案数,很裸的母函数. #include<cstdio> ...

  6. hdu_1348_Wall(凸包)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 题意:让你求n个点的凸包,凸包离点的距离为l 题解:就凸包周长+一个半径为l的圆周长 #incl ...

  7. 在Mac OS X系统下 用dd命令将iso镜像写入u盘

    一. Mac下将ISO写入U盘可使用命令行工具dd,操作如下: 1.找出U盘挂载的路径,使用如下命令:diskutil list2.将U盘unmount(将N替换为挂载路径):diskutil unm ...

  8. Html wmode 标签参数详解

    原文出处:http://blog.sina.com.cn/s/blog_4532d8b50101g2sw.html 在网页中嵌入swf文件时,经常会用到wmode这个参数,而嵌入的swf出现的一些问题 ...

  9. velocity 语法

    1,如果调用是第一条就加上类名current. #foreach($info in $aboutlist) <li><a href="$!{info.href}" ...

  10. 萝卜德森的sublime笔记中文翻译版

    我已经使用subliem编辑器版本2接近2个月了,并且我在其中找到了一堆有用的技巧.我发觉应该写下这些技巧,为那些对此感兴趣的人们.我会尽力的详细描述,那些看起来像魔法一样的东西,因为很多非常“酷”的 ...