题目链接: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. Android应用测试性能的工具Emmagee,导出文件格式问题分析

    原文引用自:http://www.open-open.com/lib/view/open1367026451078.html Emmagee是监控指定被测应用在使用过程中占用机器的CPU.内存.流量资 ...

  2. 可写的计算监控(Writable computed observables)

    新手可忽略此小节,可写依赖监控属性真的是太advanced了,而且大部分情况下都用不到. 一般情况下,计算监控的值是通过其他监控属性的值计算出来的,因此它是只读的.这个看似很奇怪,我们有什么办法可以让 ...

  3. oc 是否允许远程通知

    UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSett ...

  4. js iframe跨域访问

    1.什么是跨域? 2.前台解决跨域几种方法 2.1 动态创建script 2.2 使用document.domain 2.3使用HTML5新属性postMessage 2.4 利用iframe和loc ...

  5. 会话技术cookie和session详解

    什么是会话 会话可简单理解为:用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 会话技术解决了什么问题 每个用户与服务器进行交互的过程中,各自会有一 ...

  6. JPA使用的HelloWorld

    一.使用JPA持久化对象的步骤 •创建 persistence.xml, 在这个文件中配置持久化单元 –需要指定跟哪个数据库进行交互; –需要指定 JPA 使用哪个持久化的框架以及配置该框架的基本属性 ...

  7. .net core 读取配置文件

    /// <summary> /// 读取配置信息 /// </summary> public class Zconfig { #region 读取配置信息 /// <su ...

  8. 《Windows驱动开发技术详解》之定时器

    I/O定时器 I/O定时器是DDK提供的一种定时器.它每个1s钟系统会调用一次I/O定时器例程.I/O定时器例程运行在DISPATCH_LEVEL级别,因此在这个例程中不能使用分页内存,否则会引起页故 ...

  9. git基本命令--status, add, diff, commit, log

    git status: git status命令的输出十分详细,但其用语有些繁琐. 如果你使用 git status -s 命令或 git status --short 命令,你将得到一种更为紧凑的格 ...

  10. C++primer 9.43

    题目要求:编写一个函数,接受三个string参数s,oldVal和newVal.使用迭代器及insert和erase函数将s中所有oldVal替换为newVal.测试你的程序,用它替换通用的简写形式, ...