1414

破题 又逼着用stl 卡内存 trie树太耗了 水不过去

用set存字符串 set可以自己按一定顺序存 且没有重复的 再用lower_bound二分查找字符串的第一次出现 接着往后找就行了

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<set>
#include<string>
using namespace std;
#define N 10010
set<string>q;
set<string>::iterator it;
int kk;
string ys = "sun";
char ss[];
bool cmp(string s)
{
int i,tk = (int)s.size();
if(tk<kk)
return false;
for(i = ; i < kk ; i++)
{
if(s[i]!=ss[i])
return false;
}
return true;
}
int main()
{
char c;
q.insert(ys);
while(cin>>c)
{
cin>>ss;
if(c=='?')
{
cout<<ss<<endl;
kk = strlen(ss);
if(q.size())
{
it = lower_bound(q.begin(),q.end(),ss);
int k;
for(k=; it!=q.end()&&cmp(*it)&&k<;it++,k++)
cout<<" "<<(*it)<<endl;
}
}
else
{
q.insert(ss);
}
getchar();
}
return ;
}

1414. Astronomical Database(STL)的更多相关文章

  1. ural1414 Astronomical Database

    Astronomical Database Time limit: 2.0 secondMemory limit: 64 MB After the Hubble telescope had been ...

  2. [洛谷日报第39期]比STL还STL?——pbds

    [洛谷日报第39期]比STL还STL?——pbds   洛谷科技 发布时间:18-08-3116:37 __gnu_pbds食用教程 引入 某P党:“你们C++的STL库真强(e)大(xin),好多数 ...

  3. uva 1592 Database (STL)

    题意: 给出n行m列共n*m个字符串,问有没有在不同行r1,r2,有不同列c1,c2相同.即(r1,c1) = (r2,c1);(r1,c2) = (r2,c2); 如 2 3 123,456,789 ...

  4. UVa - 1592 Database(STL,优化)

    给一个n行m列的数据库表格,问有没有两个行 r1,r2 和 c1,c2,满足(r1,r2)的元素=(c1,c2)的元素. n≤10000,m≤10. 直接枚举4个肯定会T的.可以只枚举c1 c2,然后 ...

  5. STL笔记(2) STL之父访谈录

    年3月,dr.dobb's journal特约记者, 著名技术书籍作家al stevens采访了stl创始人alexander stepanov. 这份访谈纪录是迄今为止对于stl发展历史的最完备介绍 ...

  6. (转)STL

    C++容器类 C++中的容器类包括“顺序存储结构”和“关联存储结构”,前者包括vector,list,deque等:后者包括set,map,multiset,multimap等. 若需要存储的元素数在 ...

  7. STL之父Stepanov谈泛型编程的发展史

    这是一篇Dr. Dobb's Journal对STL之父stepanov的采访.文中数次提到STL的基本思想.语言的特性.编程的一些根本问题等,非常精彩.这篇文章让我想去拜读下stepanov的大作& ...

  8. UVa第五章STL应用 习题((解题报告))具体!

    例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h&g ...

  9. Database Replay和Consolidated Database replay

    简介 在数据库的迁移和升级场景中,我们经常会遇到一个问题:在做压力测试时,如何模拟真实的业务压力,解决这个问题的方法有很多,比如:应用方开发模拟程序或者使用压力测试工具模拟,如load runner, ...

随机推荐

  1. ios 数字禁止变成电话号码

    1.使用meta来限制页面不转换电话号码   <meta name="format-detection"content="telphone=no"/> ...

  2. php 生成器 入门理解

    概念太晦涩,看不懂,直接上例子: 问题:得到一个1-1000000的整数数组,然后用foreach遍历输出 如果没有生成器,这样做: $arr=range(1,1000000);//这个函数最终会返回 ...

  3. ubuntu更新源,简单两步搞定

    1.启动器中打开Ubuntu软件中心 2.鼠标顶部面板点击编辑选择软件源(163.sohu) 搞定!

  4. Eclipse编辑器基本设置

    1.添加行号 在边缘处右键 2.改字体 字体的一般配置 3.去掉拼写错误检查 4.Java代码风格 代码格式化 Ctrl + Shift + F 之后点击右边的New按钮,新建一个风格. 点击OK 上 ...

  5. Only the original thread that created a view hierarchy can touch its views

    在调试软件的时候出现如下的错误: 01-05 20:53:36.492: E/ZZShip(2043): android.view.ViewRootImpl$CalledFromWrongThread ...

  6. 收录一个简单的css类库

    /* CSS liberary */.yahei {    font-family: "Microsoft Yahei", "Tahoma", "Si ...

  7. dive into python 读笔(3)

    chapter 6 异常和文件处理: # 使用 try...except 来捕捉异常 # 使用 try...finally 来保护额外的资源 # 读取文件 # 在一个 for循环中一次赋多个值 # 使 ...

  8. ajax加php实现三级联动

    js代码 <script type="text/javascript">    function get_next(t,pid){  //当前元素的id,当前optio ...

  9. Eat the Trees hdu 1693

    Problem DescriptionMost of us know that in the game called DotA(Defense of the Ancient), Pudge is a ...

  10. JAVA面试题:69道Spring面试题和答案

    目录 Spring 概述 依赖注入 Spring beans Spring注解 Spring数据访问 Spring面向切面编程(AOP) Spring MVC Spring 概述 1. 什么是spri ...