题意:统计一个数出现了多少次,统计后删去它所有的出现。思路:乱搞。。自己没事写的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. 忍不住还是手写了一遍博客的css

    F12边调边改,的一点一点撸出来这个效果.感觉已经可以了.日历感觉没什么用直接隐藏了.

  2. 2020i春秋新春战疫

    简单的招聘系统 登陆这里就可以注入 查询这里也可以注入 从登陆这里注入把 爆破数据库名 爆破表名 列名 flag 就很奇怪跑出来的东西 重开容器跑一遍列,估计是flaaag.后面可能是发生了502 再 ...

  3. [linux][MongoDB] mongodb学习(一):MongoDB安装、管理工具、

    参考原文:http://www.cnblogs.com/kaituorensheng/p/5118226.html linux安装完美实现! 1. mongoDB安装.启动.关闭 1.1 下载安装包 ...

  4. Golang交付至Kubernetes

    目录 0.前言 1.Go服务构建 1.1.制作Go服务镜像底包 1.2.制作slave基础镜像底包 1.2.1.Golang镜像 1.2.2.Docker镜像 2.创建golang流水线 3.流水线构 ...

  5. C#栈、堆的理解(2)

    接上一遍博文有关值类型和引用类型的相关概念. 所有值类型数据存放:栈(内存) 引用类型的数据存放:堆(内存) 栈:可以认为是一本书的目录部分称其为栈.栈可快速检索,运行速度比堆大,而且栈的空间小得多. ...

  6. 支付宝开源非侵入式 Android 自动化测试工具 Soloπ

    Soloπ(SoloPi)是支付宝开源的一个无线化.非侵入式的Android自动化测试工具,公测版拥有录制回放.性能测试.一机多控三项主要功能,能为测试开发人员节省宝贵时间. 本文是SoloPi团队关 ...

  7. 为什么要你们现在要学习python

    说学习python之前,我们先来聊聊其他的.我们都认为成功靠的是勤奋和努力,但是事实是只靠勤奋和努力是不一定会成功的,而且很大一部分都不会成功. 你有没有想过,同样是做企业,有些公司年收入百万,而腾讯 ...

  8. web 之 tomcat 8.5 和9.0如何进入manager?

    tomcat 8.5 和9.0如何进入manager? 第一步找到tomcat-user.xml文件 第二步添加如下代码 <role rolename="manager-gui&quo ...

  9. 【JAVA基础】11 Scanner类

    1. Scanner的概述 一个可以使用正则表达式来解析基本类型和字符串的简单文本扫描器. Scanner 使用分隔符模式将其输入分解为标记,默认情况下该分隔符模式与空白匹配.然后可以使用不同的 ne ...

  10. “Too many texture interpolators would be used for ForwardBase pass”

    CGPROGRAM 下加一个 #pragma target 4.0 转载于:https://www.cnblogs.com/alps/p/7101092.html