题意:统计一个数出现了多少次,统计后删去它所有的出现。思路:乱搞。。自己没事写的hash,不过赶脚效率有点低。

 #pragma comment(linker, "/STACK:10240000,10240000")

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <ctime>
#include <cctype>
#include <set> using namespace std; #define mem0(a) memset(a, 0, sizeof(a))
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define define_m int m = (l + r) >> 1
#define Rep(a, b) for(int a = 0; a < b; a++)
#define lowbit(x) ((x) & (-(x)))
#define constructInt4(name, a, b, c, d) name(int a = 0, int b = 0, int c = 0, int d = 0): a(a), b(b), c(c), d(d) {}
#define constructInt3(name, a, b, c) name(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
#define constructInt2(name, a, b) name(int a = 0, int b = 0): a(a), b(b) {} typedef double db;
typedef long long LL;
typedef pair<int, int> pii;
typedef multiset<int> msi;
typedef multiset<int>::iterator msii;
typedef set<int> si;
typedef set<int>::iterator sii;
typedef vector<int> vi; const int dx[] = {, , -, , , , -, -};
const int dy[] = {, -, , , -, , , -};
const int maxn = 1e6 + ;
const int maxm = 1e5 + ;
const int maxv = 1e7 + ;
const int max_val = 1e6 + ;
const int MD = 1e9 +;
const int INF = 1e9 + ;
const double PI = acos(-1.0);
const double eps = 1e-; inline int ReadInt() {
char c = getchar();
while(!isdigit(c)) c = getchar(); int x = ;
while(isdigit(c)) {
x = x * + c - '';
c = getchar();
}
return x;
} inline void WriteInt(int i) {
int p = ;
static int buf[];
if(i == ) buf[p++] = ;
else while(i) {
buf[p++] = i % ;
i /= ;
}
for(int j = p - ; j >= ; j--) putchar('' + buf[j]);
}
template<class T> struct HashList {
vector<T> hash[max_val];
HashList<T>() { }
void clear() { mem0(hash); }
void insert(T x) { hash[x % max_val].push_back(x); }
void erase(T x) {
int node = x % max_val;
for (int i = ; i < hash[node].size(); i++) {
if (hash[node][i] == x) {
hash[node].erase(hash[node].begin() + i, hash[node].begin() + i + );
return ;
}
}
}
void erase_all(T x) {
int node = x % max_val;
for (int i = ; i < hash[node].size(); i++) {
if (hash[node][i] == x) {
hash[node].erase(hash[node].begin() + i, hash[node].begin() + i + );
i--;
}
}
}
bool find(T x) {
int node = x % max_val;
for (int i = ; i < hash[node].size(); i++) {
if (hash[node][i] == x) return true;
}
return false;
}
int find_cnt(T x) {
int node = x % max_val, cnt = ;
for (int i = ; i < hash[node].size(); i++) {
if (hash[node][i] == x) cnt++;
}
return cnt;
}
}; HashList<int> Hash; int main() {
//freopen("in.txt", "r", stdin);
int n, m;
while (cin >> n >> m) {
Hash.clear();
for (int i = ; i < n; i++) {
Hash.insert(ReadInt());
}
for (int i = , x; i < m; i++) {
x = ReadInt();
WriteInt(Hash.find_cnt(x));
putchar('\n');
Hash.erase_all(x);
}
}
return ;
}

[hdu5199]统计数据的水题的更多相关文章

  1. ytu 1939:统计元音(水题)

    统计元音 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 68  Solved: 33[Submit][Status][Web Board] Descrip ...

  2. BestCoder Round #36 (hdu5199)Gunner(水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Gunner Time Limit: 8000/4000 MS (Java/Oth ...

  3. Atcoder 水题选做

    为什么是水题选做呢?因为我只会水题啊 ( 为什么是$Atcoder$呢?因为暑假学长来讲课的时候讲了三件事:不要用洛谷,不要用dev-c++,不要用单步调试.$bzoj$太难了,$Topcoder$整 ...

  4. DP+贪心水题合集_C++

    本文含有原创题,涉及版权利益问题,严禁转载,违者追究法律责任 本次是最后一篇免费的考试题解,以后的考试题目以及题解将会以付费的方式阅读,题目质量可以拿本次作为参考 本来半个月前就已经搞得差不多了,然后 ...

  5. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串“水”题 时间限制: 1 Sec  内存限制: 128 MB提交: 210  解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...

  6. [洛谷U22157]刷水题(数位dp)(hash)

    题目背景 做正经题是不可能做正经题的,这辈子都不可能做正经题的,毒瘤题又不会做毒瘤题,就是水题这种东西,才维持了蒟蒻的信心: 题目描述 这里有N+1 道水题,编号分别为0 ~N+1 ,每道水题都有它自 ...

  7. [ZPG TEST 114] 阿狸的英文名【水题】

    1.      阿狸的英文名 阿狸最近想起一个英文名,于是他在网上查了很多个名字.他发现一些名字可以由两个不同的名字各取一部分得来,例如John(约翰)的前缀 “John”和Robinson(鲁滨逊) ...

  8. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  9. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

随机推荐

  1. skynet启动流程及调用服务

     3.基本原理 3.1启动流程  1.skynet-src/skynet_main.c 这个是main()函数所在,主要就是设置一下lua的环境.默认的配置.打开config配置文件,并修改默认配置. ...

  2. Python 【面试强化宝典】

    四大数据类型的常用方法 列表常用方法 #1. append 用于在列表末尾追加新的对象 a = [1,2,3] a.append(4) #the result : [1, 2, 3, 4] #2. c ...

  3. centos下python多版本管理(pyenv+python+virtualenv+ipython)

    pyenv是个多版本python管理器,可以同时管理多个python版本共存,如pypy,miniconde等等 1 环境准备 安装相关软件和pyenv1.1 安装相关软件yum install -y ...

  4. java学习(第三篇)String类

    一.创建一个字符串 1.String(char a[]):用一个字符数组a创建一个string类型 char a[]= {'h','e','l','l','o'}; String s=new Stri ...

  5. cocos2dx新建项目

    首先你得下载好cococs2dx,还有python2.x版本,还有vs2017 然后cmd在你Cocos2dx的路径下输入 python setup.py 然后你就回车回车回车 然后重新打开cmd 这 ...

  6. 对 ThreadLocal 的了解(一)

    Threadlocal ThreadLocal 在我个人理解范围内,主要作用是在同一个线程里面,去共享某个数据给这个线程在不同的阶段去使用. 本次使用范围 在集成 pageOffice 在线 word ...

  7. SpringBoot 集成Swagger2自动生成文档和导出成静态文件

    目录 1. 简介 2. 集成Swagger2 2.1 导入Swagger库 2.2 配置Swagger基本信息 2.3 使用Swagger注解 2.4 文档效果图 3. 常用注解介绍 4. Swagg ...

  8. QML-AES加解密小工具

    Intro 为了解码网课视频做的小工具,QML初学者可以参考一下. 项目地址 Todo 在插入新条目时,ListView不会自动根据section进行重排,因此出现同一个文件夹重复多次的现象.目测强行 ...

  9. MYSQL隔离级别 与 锁

    1.四种隔离级别下数据不一致的情况   脏读 不可重复读 幻读 RU 是 是 是 RC(快照读) 否 是 是 RC(当前读) 否 否 是 RR(快照读) 否 否 是 RR(当前读) 否 否 否 Ser ...

  10. 【STM32 .Net MF开发板学习-05】PC通过Modbus协议远程操控开发板

    从2002年就开始接触Modbus协议,以后陆续在PLC.DOS.Windows..Net Micro Framework等系统中使用了该协议,在我以前写的一篇博文中详细记载了这一段经历,有兴趣的朋友 ...