一场2012天津网络预选赛的题,签到题。

但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决。

一开始用的Char [] 后来改成了string,STL和string搭配起来才好用啊。

 #include <algorithm>
#include <iostream>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map> using namespace std; int N,M,T;
map <string ,int> dic;
string list[];
int table[]={,,,,,,,,,,,,,,,,,,,,,,,,,};
int main()
{
cin >> T;
string s;
while(T--)
{
cin >> N >> M;
for(int i=;i<N;i++) {
cin >> list[i];
}
dic.clear();
for(int i=;i<M;i++)
{
cin >> s;
string num;
for(int k=;k < (int)s.size();k++)
{
num += table[s[k]-'a'] + '';
}
//cout << num << endl;
map<string ,int>::iterator it = dic.find(num);
if(it == dic.end()){
dic.insert(make_pair(num,));
}
else
it->second++;
}
map<string , int>::const_iterator notFound(dic.end());
map<string , int>::const_iterator pos;
for(int i=;i<N;i++)
{
if((pos = dic.find(list[i])) == notFound)
printf("0\n");
else
printf("%d\n",pos->second);
}
}
}

HDU4287-STL模拟水题的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  3. 模拟水题,查看二维数组是否有一列都为1(POJ2864)

    题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...

  4. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  5. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  6. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  7. Mishka and Contest(模拟水题)

    Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...

  8. 模拟水题,牛吃草(POJ2459)

    题目链接:http://poj.org/problem?id=2459 题目大意:有C头牛,下面有C行,每头牛放进草地的时间,每天吃一个草,总共有F1个草,想要在第D的时候,草地只剩下F2个草. 解题 ...

  9. 洛谷 1079 Vigenère 密码——模拟水题

    题目:https://www.luogu.org/problemnew/show/P1079 大水题. #include<iostream> #include<cstdio> ...

随机推荐

  1. java中使用阻塞队列实现生产这与消费这之间的关系

    需求如下: 有一个生产者和一个消费者,生产者不断的生产产品,消费这不断的消费产品.产品总数为N. 1.生产顺序按队列的方式,先进先出. 2.生产者和消费这可以同时进行. 3.当生产者生产了N个产品后不 ...

  2. C#以管理员用户打开某个程序

    static void Main(string[] args) { string path = @"C:\Windows\AppPatch\AppLoc.exe"; Process ...

  3. 利用H5本地存储localStorage、sessionStorage

    最近的业务处理上,要使用cookie缓存储一下数据,公司的cookie还搞出点问题.而用户的浏览器都是利用微信的内置,普遍支持h5的本地存储.于是利用了这个... 现代浏览器普遍开始支持H5本地存储, ...

  4. jQuery的Cookie使用

    为程序设置Cookie,可以在C#内进行,也可以在前端进行.如jQuery的Cookie也是一个很不错的插件. 在使用之前,可以先使用NuGet来安装cookie: 在MVC的视图中,引用jQuery ...

  5. SQL查询今天、昨天、7天内、30天 - 转

    今天的所有数据:select * from 表名 where DateDiff(dd,datetime类型字段,getdate())=0 昨天的所有数据:select * from 表名 where ...

  6. 绍一集训Round#1

    到了之后看题,T1一看发现真熟悉,和之前做的一道题真的像,然后内心: 这里是绍一啊,不可能就出这么简单的题 我题意没理解错啊,这不是单独计算每条边的贡献么 维护一个人数的大小,然后直接搞一波就可以了吧 ...

  7. 从源码的角度再看 React JS 中的 setState

    在这一篇文章中,我们从源码的角度再次理解下 setState 的更新机制,供深入研究学习之用. 在上一篇手记「深入理解 React JS 中的 setState」中,我们简单地理解了 React 中 ...

  8. cf946d 怎样逃最多的课dp

    来源:codeforces                                              D. Timetable Ivan is a student at Berland ...

  9. linux第三次读书笔记

    第七章:链接 一.编译器驱动程序 编译系统提供的调用预处理器.编译器.汇编器和链接器来构造目标文件的程序. 二.静态链接 三.目标文件 三种形式: 1.可重定位目标文件: 2.可执行目标文件: 3.共 ...

  10. 小学四则运算APP 第二次冲刺-第二天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第二次冲刺阶段时间:11.29~12.09 本次发布的判断题功能界面的设置: activity_panduan_set.xml: < ...