题目链接: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. B - 小Y上学记——小Y的玩偶

    B - 小Y上学记——小Y的玩偶 Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others) ...

  2. HTML 概述

    一.hello world<!--根标签--><html> <!--头部--> <head> <!--标题标签--> <title&g ...

  3. Quartz(任务调度)- 入门学习

    参照:http://blog.csdn.net/szwangdf/article/details/6158646 1.自定义定时任务管理类 QuartzManager 参照大神基础上新增:1.添加jo ...

  4. android 常用

    1:常用之动画(View Animation,Drawable Animation,Property Animation) http://blog.csdn.net/huxueyan521/artic ...

  5. Java 处理图片 base64 编码的相互转换

    哈喽大家好我是刘德华. 今天项目优化了一下上传头像的功能.采用 imagecropper 插件完成裁剪图片的效果. 这个插件裁剪完的图片都是 base64 加密的字符串,上传头像也就涉及到了如何把加密 ...

  6. Windows API 之 GetModuleHandle

    Retrieves a module handle for the specified module. The module must have been loaded by the calling ...

  7. 缺少对象 WScript 问题解决方法

    方法一: 先把脚本保存起来(保证你的脚本能正确运行),例如命名为test.vbs 然后在QTP写以下脚本就可以正确运行了! Dim oShell Set oShell =CreateObject (& ...

  8. leetcode415---字符串大数相加

    Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...

  9. python unitest基本

    基本 import unittest class OneTest(unittest.TestCase): def setUp(self): self.verificationErrors = [] s ...

  10. Html:upload

    文件上传框 有时候,需要用户上传自己的文件,文件上传框看上去和其它 文本域差不多,只是它还包含了一个浏览按钮.访问者可以通 过输入需要上传的文件的路径或者点击浏览按钮选择需要上传 的文件. 代码格式: ...