bzoj 2761 [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 3210 Solved: 1186
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6
Sample Output
1 2 3 4 5 6
HINT
对于30%的数据,1 <= N <= 100,给出的数不大于100,均为非负整数;
对于50%的数据,1 <= N <= 10000,给出的数不大于10000,均为非负整数;
对于100%的数据,1 <= N <= 50000,给出的数在32位有符号整数范围内。
提示:
由于数据量很大,使用C++的同学请使用scanf和printf来进行输入输出操作,以免浪费不必要的时间。
【思路】
搞一个哈希表 =-=
像我这种有stl依赖症的人用个map就够了 =-=
【代码】
#include<map>
#include<cstdio>
#include<iostream>
using namespace std; map<int,int> mp;
int n,sz,q[];
void read(int& x) {
char c=getchar(); int f=;x=;
while(!isdigit(c)){if(c=='-') f=-; c=getchar();}
while(isdigit(c)) x=x*+c-'',c=getchar();
x*=f;
}
int main() {
int T;
read(T);
while(T--) {
sz=; mp.clear();
read(n);
int x;
for(int i=;i<n;i++) {
read(x);
if(!mp.count(x)) q[++sz]=x,mp[x]=;
}
for(int i=;i<sz;i++) printf("%d ",q[i]);
printf("%d\n",q[sz]);
}
return ;
}
bzoj 2761 [JLOI2011]不重复数字(哈希表)的更多相关文章
- BZOJ 2761: [JLOI2011]不重复数字 水题
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2100 Solved: 809 题目连接 http:// ...
- BZOJ 2761: [JLOI2011]不重复数字 hash哈希
题目就不贴了 点我看题 题意:这题题意很简明,就是给一个序列,把序列里相同的删掉,然后输出,按原数列顺序. 思路:这题之前QZZ和ZN大神犇叫我去做,辣时还不会hash,就留着了.最近某夏令营学会了h ...
- BZOJ 2761: [JLOI2011]不重复数字 set
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- bzoj 2761: [JLOI2011]不重复数字 (map||Treap)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2761 思路: map标记 实现代码: #include<bits/stdc++.h&g ...
- bzoj 2761: [JLOI2011]不重复数字
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #d ...
- bzoj 2761: [JLOI2011]不重复数字【hash】
map会T,双hash会冲突--于是非酋写了个三hash #include<iostream> #include<cstdio> #include<cstring> ...
- 2761: [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1770 Solved: 675[Submit][Stat ...
- 2761: [JLOI2011]不重复数字(平衡树)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2133 Solved: 825[Submit][Stat ...
- 【BZOJ】2761: [JLOI2011]不重复数字(set+巨水题+超坑题)
http://www.lydsy.com/JudgeOnline/problem.php?id=2761 太水了,不说了. 但是这格式错误我已经没话说了....行末不能有空格 #include < ...
随机推荐
- 【转】Java编程之字符集问题研究
发现这是对字集说得最明了的一篇文章了. 转发自:http://tomcat-oracle.iteye.com/blog/2037160 1. 概述 本文主要包括以下几个方面:编码基本知识,java,系 ...
- leetcode problem 6 ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...
- django 学习点滴
django连接数据库要安装第三方包,比如mysql的就是 python-mysqldb, 用apt-cache search python-mysql 搜索一下. django的project可以放 ...
- 『奇葩问题集锦』function * (next){ 执行报错 SyntaxError: Unexpected token *
这是因为 app.use(function * (){ 语句中有一个 * ,这种方式被称为generator functions ,一般写作function *(){...} 的形式,在此类func ...
- pdo如何防止 sql注入
我们使用传统的 mysql_connect .mysql_query方法来连接查询数据库时,如果过滤不严,就有SQL注入风险,导致网站被攻击,失去控制.虽然可以用 mysql_real_escape_ ...
- C语言结构体中的函数指针
这篇文章简单的叙述一下函数指针在结构体中的应用,为后面的一系列文章打下基础 本文地址:http://www.cnblogs.com/archimedes/p/function-pointer-in ...
- [GUIDE] How to install Scipy in Maya Windows 64 bit - Google 网上论坛 - Google Chrome
I've seen a lot of queries about getting scipy working in Maya (Windows 64 bit) with a few not 100% ...
- jquery实现抽奖
用jquery实现抽奖小程序 用jquery实现抽奖小程序 这些日子,到处都可以看到关于微信小程序的新闻或报到,在博客园中写关于微信小程序的也不少.但是今天我要说的不是微信小程序,而是用简单的jq ...
- 在windows下创建.gitignore文件
1.使用另存为的方式 2.在win7下,文件名输入 ”.gitignore.“ http://hbiao68.iteye.com/blog/2055496 http://lyhopq.github ...
- pythom 安装MySQL-pythom的问题
链接一:http://blog.csdn.net/dqatsh/article/details/2418663 链接二:http://codingnow.cn/language/159.html 链接 ...