HDU4287-STL模拟水题
一场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模拟水题的更多相关文章
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- 模拟水题,查看二维数组是否有一列都为1(POJ2864)
题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...
- UVA 10714 Ants 蚂蚁 贪心+模拟 水题
题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
- Mishka and Contest(模拟水题)
Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...
- 模拟水题,牛吃草(POJ2459)
题目链接:http://poj.org/problem?id=2459 题目大意:有C头牛,下面有C行,每头牛放进草地的时间,每天吃一个草,总共有F1个草,想要在第D的时候,草地只剩下F2个草. 解题 ...
- 洛谷 1079 Vigenère 密码——模拟水题
题目:https://www.luogu.org/problemnew/show/P1079 大水题. #include<iostream> #include<cstdio> ...
随机推荐
- 上传头像,layui上传图片
layui上传与bootstrap上传相似,只是不需要下插件, layui自带的已够用 先看一下前台界面,这里是用到的上传头像 先点击开始上传,头像上传至服务器中, 返回json添加至form表单中, ...
- CMD命令查看当前电脑安装所有版本.NET Core SDK(转载)
dotnet --version 查看当前使用版本 dotnet --info 安装的所有版本 包括版本地址 也可用命令帮助 dotnet help 原文链接
- 【LeetCode225】 Implement Stack using Queues★
1.题目 2.思路 3.java代码 import java.util.LinkedList; import java.util.Queue; public class MyStack { priva ...
- React-使用styled-components
1.安装 npm install --save styled-components 2.简单使用 style.js: import styled from 'styled-components'; i ...
- 51Nod 1299 监狱逃离
这其实是一道树形DP的神仙题. 然后开始推推推,1 hour later样例都过不了 然后仔细一看题目,貌似像一个最小割模型,然后5min想了想建图: 首先拆点,将每个点拆成进和出两个,然后连边,边权 ...
- 蓝牙baseband概述
从蓝牙specispecification中看,基带协议主要分为8个部分来介绍的,分别是概述.物理信道.物理连接.逻辑传输.逻辑连接.封包.比特流的处理.组网行为.这里面会涉及到很多的概念,主要是在概 ...
- dp方法论——由矩阵相乘问题学习dp解题思路
前篇戳:dp入门——由分杆问题认识动态规划 导语 刷过一些算法题,就会十分珍惜“方法论”这种东西.Leetcode上只有题目.讨论和答案,没有方法论.往往答案看起来十分切中要害,但是从看题目到得到思路 ...
- REST-framework快速构建API--分页
分页简介 当数据量特别大的时候,我们通过API获取数据会非常慢,所以此时我们需要将数据"分批次"取出来,这里的"分批次"就是,分页! REST框架支持自定义分页 ...
- SqlBulkCopy简单封装,让批量插入更方便
关于 SqlServer 批量插入的方式,前段时间也有大神给出了好几种批量插入的方式及对比测试(http://www.cnblogs.com/jiekzou/p/6145550.html),估计大家也 ...
- Jmeter(二十九)_dotnet搭建本地接口服务
这里使用的服务名为Bookshelf,在github上,自行下载.要运行此服务,需要.Net Core SDK 2.1或更高版本.如果尚未安装,从.Net Core官方网站下载并安装. 在本地克隆项目 ...