Description

给出N个数,要求把其中重复的去掉,只保留第一次出现的数。
例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4。
 

Input

输入第一行为正整数T,表示有T组数据。
接下来每组数据包括两行,第一行为正整数N,表示有N个数。第二行为要去重的N个正整数。
 

Output

 
对于每组数据,输出一行,为去重后剩下的数字,数字之间用一个空格隔开。
题解:每次用 $set$ 查询一个数是否插入过即可. 
#include<bits/stdc++.h>
#define maxn 100000
using namespace std;
void setIO(string s)
{
string in=s+".in";
freopen(in.c_str(),"r",stdin);
}
set<int>S;
set<int>::iterator it;
int arr[maxn];
inline void solve()
{
int n,i,a;
scanf("%d",&n);
for(i=1;i<=n;++i)
{
scanf("%d",&a);
if(S.find(a)==S.end()) printf("%d ",a), S.insert(a);
}
S.clear();
printf("\n");
}
int main()
{
// setIO("input");
int T;
scanf("%d",&T);
while(T--) solve();
return 0;
}

  

BZOJ 2761: [JLOI2011]不重复数字 set的更多相关文章

  1. BZOJ 2761: [JLOI2011]不重复数字 水题

    2761: [JLOI2011]不重复数字 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2100  Solved: 809 题目连接 http:// ...

  2. bzoj 2761 [JLOI2011]不重复数字(哈希表)

    2761: [JLOI2011]不重复数字 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 3210  Solved: 1186[Submit][Sta ...

  3. bzoj 2761: [JLOI2011]不重复数字 (map||Treap)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2761 思路: map标记 实现代码: #include<bits/stdc++.h&g ...

  4. BZOJ 2761: [JLOI2011]不重复数字 hash哈希

    题目就不贴了 点我看题 题意:这题题意很简明,就是给一个序列,把序列里相同的删掉,然后输出,按原数列顺序. 思路:这题之前QZZ和ZN大神犇叫我去做,辣时还不会hash,就留着了.最近某夏令营学会了h ...

  5. bzoj 2761: [JLOI2011]不重复数字

    #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #d ...

  6. bzoj 2761: [JLOI2011]不重复数字【hash】

    map会T,双hash会冲突--于是非酋写了个三hash #include<iostream> #include<cstdio> #include<cstring> ...

  7. 2761: [JLOI2011]不重复数字(平衡树)

    2761: [JLOI2011]不重复数字 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2133  Solved: 825[Submit][Stat ...

  8. 2761: [JLOI2011]不重复数字(哈希表)

    2761: [JLOI2011]不重复数字 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1770  Solved: 675[Submit][Stat ...

  9. 【BZOJ】2761: [JLOI2011]不重复数字(set+巨水题+超坑题)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2761 太水了,不说了. 但是这格式错误我已经没话说了....行末不能有空格 #include < ...

随机推荐

  1. CDN-template

    ylbtech-CDN: 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   7.返回顶部   8.返回顶部   9.返回顶部   10.返 ...

  2. sticky用法

    可以用于滚动到一定距离以后让他实现定位效果. 比如滚动到50px的时候让导航栏固定定位. 用法:给最外层的div设置绝对定位 然后要固定的div设置position:sticky; top:0: 这样 ...

  3. 《图解设计模式》读书笔记3-1 Singleton模式

    目录 单例模式 饿汉式 懒汉式 线程安全的懒汉式 单例模式 确保任何情况下都只有一个实例 饿汉式 public class Singleton { //在类被加载的时候运行一次,这是本类构造函数的唯一 ...

  4. Vue过渡:CSS过渡

    一 项目结构 二 App.vue <template> <div id="app"> <transition name="fade" ...

  5. PHP 是怎么接收到请求的?

    本篇文章主要描述一下几点 ● nginx 怎么转发请求 给 PHPFPM? ● CGI 和 FastCGI 到底是个什么玩意? ● PHPFPM 是什么?有什么作用? 简单场景描述 在浏览器上访问一个 ...

  6. StatusStrip 分类: C# 2015-07-23 11:58 2人阅读 评论(0) 收藏

    通过StatusStrip显示窗体状态栏 同时将状态栏分成三部分 居左边显示相关文字信息 中间空白显示 居右边显示时间信息 1.创建窗体及添加StatusStrip   默认StatusStrip名称 ...

  7. 使用HystrixCommand封装http请求

    1.引入依赖 要排除hystrix-core里的archaius-core,否则报错 <dependency> <groupId>com.netflix.hystrix< ...

  8. 265-Keystone II JESD204B 66AK2L06 评估模块 (现行) XEVMK2LX

    Keystone II JESD204B 66AK2L06 评估模块 (现行) XEVMK2LX 一. 板卡概述The XEVMK 2LX is a full-featured evaluation ...

  9. 微信小程序(18)-- 自定义头部导航栏

    最近做的项目涉及相应的页面显示相应的顶部标题,所以就需要自定义头部导航了. 首先新建一个顶部导航公用组件topnav,导航高度怎么计算? 1.wx.getSystemInfo 和 wx.getSyst ...

  10. Vue:子组件如何跟父组件通信

    我们知道,父组件使用 prop 传递数据给子组件.但子组件怎么跟父组件通信呢?这个时候 Vue 的自定义事件系统就派得上用场了. 使用 v-on 绑定自定义事件 每个 Vue 实例都实现了事件接口,即 ...