BZOJ 2761: [JLOI2011]不重复数字(傻逼题)
来源:互联网 发布:双色球参选数据2017年 编辑:程序博客网 时间:2024/05/29 09:10
2761: [JLOI2011]不重复数字
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2885 Solved: 1064
[Submit][Status][Discuss]
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
对于每组数据,输出一行,为去重后剩下的数字,数字之间用一个空格隔开。
Sample Input
2
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6
Sample Output
1 2 18 3 19 6 5 4
1 2 3 4 5 6
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来进行输入输出操作,以免浪费不必要的时间。
解题思路:
map
/************************************************************** Problem: 2761 User: mogu Language: C++ Result: Accepted Time:920 ms Memory:1672 kb****************************************************************/ #include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#include <algorithm>#include <map>#include <vector>#define ll long long using namespace std;const int MAXN = 50000 + 10;int read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9'){if(ch == '-') f *= -1; ch = getchar();} while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();} return x * f;}map<int, int> st;int N, x;int main(){ int T = read(); while(T--) { N = read();st.clear();bool flag = true; for(int i=0;i<N;i++) { x = read(); if(st[x] == 0) { if(!flag) printf(" "); printf("%d", x); flag = false; } st[x] = 1; } printf("\n"); } return 0;}
0 0
- BZOJ 2761: [JLOI2011]不重复数字(傻逼题)
- bzoj 2761: [JLOI2011]不重复数字
- bzoj 2761: [JLOI2011]不重复数字 排序
- 【BZOJ 2761】[JLOI2011]不重复数字
- BZOJ 2761: [JLOI2011]不重复数字
- BZoj 2761: [JLOI2011]不重复数字 (set
- bzoj 2761 [JLOI2011]不重复数字
- [bzoj-2761][JLOI2011]不重复数字 题解
- BZOJ[2761][JLOI2011]不重复数字 STL
- bzoj 2761: [JLOI2011]不重复数字
- BZOJ [JLOI2011]不重复数字
- BZOJ 大视野 2761: [JLOI2011]不重复数字 解题报告
- 2761: [JLOI2011]不重复数字
- 2761: [JLOI2011]不重复数字
- 【JLOI2011】不重复数字
- [BZOJ2761][JLOI2011]不重复数字(splay)
- 【bzoj2761】[JLOI2011]不重复数字
- bzoj2761 [JLOI2011]不重复数字
- 二分查找
- JUnit4常用注释
- ORACLE迁移中的一些经验(一)批量导出sequence
- Maven入门指南③:坐标和依赖
- 常用的android-图片加载类库----Fresco
- BZOJ 2761: [JLOI2011]不重复数字(傻逼题)
- 老板如何忽悠人
- 简单Dream-please use a kernel appropriate for your CPU.
- 说说cygwin
- UITableView 分割线不靠左(未补全),删除多余分割线问题
- Maven入门指南④:仓库
- MyEclipse 2014跟2015破解
- android 在activity上的悬浮框、利用WindowManager和PopupWindow实现
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]