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 < ...
随机推荐
- 【ADO.NET】3、从TXT中导入数据到数据库
数据库字段与类型id int,Name nvarchar(20),Age int TXT文本内容为 小高-20张三-18李四-19 private void btnInput_Click(object ...
- JVM - 内存溢出问题排查相关命令jcmd jmap
jcmd http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jcmd.html jcmd-l 列出正在执行的JAVA进程ID ...
- PHPUML 生成UML
Selecting the UML/XMI version To select which version of the UML/XMI standards you want your XMI to ...
- PHP curl 采集内容之规则 1
<?phpheader("Content-type:text/html; charset=utf-8");$pattern = '/xxx(.*)yyyy/isU'; //i ...
- C#XML创建与节点对象引用
我们在创建xml过程中会遇到不同的级别有相同节点的情况.如下面的xml: <?xml version="1.0" encoding="GBK"> & ...
- php中getimagesize函数的用法
php获取图片信息getimagesize,php自带函数.获取图片的类型,尺寸的方法有许多,该函数仅是方法之一. getimagesize() 函数将测定任何 GIF,JPG,PNG,SWF,SWC ...
- Poco之ftp获取文件列表以及下载文件
#include <iostream>#include <string>#include <vector>#include <algorithm>#in ...
- 修改phpmyadmin上传文件大小限制
当你想将SQL语句,导入phpmyadmin 时,发现自己的sql语句文本大小 大于 phpmyadmin的课上传的文本大小. 默认phpmyadmin上传文件大小为2M,如果想要phpmyadmin ...
- ubuntu导出文件
ye@aliyun:python$ ./deploy.sh backup static-rw-r--r-- 1 ye ye 174K 2014-03-22 10:36 ./backup/fbz_sta ...
- C与OC、C++的区别
C语言的特点:1)C语言是结构化语言,层次清晰,调试和维护比较容易2)表现能力和处理能力比较强,可直接访问内存的物理地址3)c语言实现对硬件的编辑,c语言课用语系统软件的开发,也可用语应用软件的开发, ...