多校 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 ...
随机推荐
- id和instancetype的异同
相同点: 都可以作为方法返回值类型 在initWithName:方法中是一样的,例如: - (id)initWithName:(NSString *)name; - (instancetype)ini ...
- thinkPHP框架学习笔记
class ZhuantiAction extends Action { public function index() { $name = trim($this->_get('name')); ...
- robotframework代码定位感悟
robotframework代码定位感悟: 在做自动化的时候,有时候还是要考虑真实的操作,考虑人为反应,网络,页面渲染,服务器处理请求的过程及数据是否真实到达响应的位置, 不能一味的按照程序的速度 去 ...
- struts2 result type的类型
一共十种类型 1.dispatcher 默认的类型,相当于servlet的foward,服务器端跳转.客户端看到的是struts2中配置的地址,而不是真正页面的地址.一般用于跳转到jsp页面 2.re ...
- sqlserver 经典入门基础书籍
1.SQLServer2005T-SQL数据库设计 作者:胡百敬等著 ISBN:10位[7121053632]13位[9787121053634] 出版社:电子工业出版社 出版日期:2008-1-1 ...
- Oracle SQL 内置函数大全
SQL中的单记录函数 1.ASCII 返回与指定的字符对应的十进制数;SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ...
- opencv使用convexityDefects计算轮廓凸缺陷
引自:http://www.xuebuyuan.com/1684976.html http://blog.csdn.net/lichengyu/article/details/38392473 htt ...
- VBS操作JS网页元素实例
'=========================================================================='' VBScript Source File - ...
- Linux下tomcat的安装详解
Linux下tomcat的安装详解 来源: ChinaUnix博客 日期: 2007.01.21 22:59 (共有0条评论) 我要评论 一,安装前的准备:1,Linux版本:我的是企业版.(至于红帽 ...
- ACboy needs your help again!
ACboy needs your help again! Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Ja ...