题意:统计一个数出现了多少次,统计后删去它所有的出现。思路:乱搞。。自己没事写的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. phpMyAdmin后台文件包含溯源

    先上大佬解释的漏洞原理链接 https://mp.weixin.qq.com/s?__biz=MzIzMTc1MjExOQ==&mid=2247485036&idx=1&sn= ...

  2. APT32入侵我国,试图窃取COVID-19相关情报

    新闻一篇: 一直以来,APT32都以东南亚为攻击目标,并且是近几年来针对中国大陆进行攻击活动最活跃的APT攻击组织,没有之一.此次再将目标对准中国,与新冠疫情离不开关系. 4月22日,Fireye发布 ...

  3. mybatis源码学习:基于动态代理实现查询全过程

    前文传送门: mybatis源码学习:从SqlSessionFactory到代理对象的生成 mybatis源码学习:一级缓存和二级缓存分析 下面这条语句,将会调用代理对象的方法,并执行查询过程,我们一 ...

  4. pytorch 孪生神经网络DNN

    代码内容请见: https://github.com/LiuXinyu12378/DNN-network

  5. 2层感知机(神经网络)实现非线性回归(非线性拟合)【pytorch】

    import torch import numpy import random from torch.autograd import Variable import torch.nn.function ...

  6. 使用 Junit + Mockito 实践单元测试

    一.前言 相信做过开发的同学,都多多少少写过下面的代码,很长一段时间我一直以为这就是单元测试... @SpringBootTest @RunWith(SpringRunner.class) publi ...

  7. 哈希Hash定义

    Hash,一般翻译做"散列”,也有直接音译为"哈希"的,就是把任意长度的输入(又叫做预映射, pre-image),通过散列算法,变换成固定长度的输出,该输出就是散列值. ...

  8. python学习05条件分支

    '''if '''a=1b=2if a==b: print(a)print(b) '''与C语言不同,python语言的if格式必须为if 布尔表达式:(冒号不能省略)其二,python有严格的缩进格 ...

  9. opencv-2-VS2017与QT显示图像

    opencv-2-VS2017与QT显示图像 opencvqtVSC++ 目的 使用 VS 构建第一个 opencv 程序 使用 QT 构建 第一个 opencv 程序 VS 导入 QT 程序 开始 ...

  10. 将Spring Boot应用程序注册成为系统服务

    文章目录 前期准备 打包成可执行jar包 注册成为liunx服务 System V Init Systemd Upstart 在Windows中安装 Windows Service Wrapper J ...