[BZOJ2761][JLOI2011]不重复数字 暴力
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2761
直接暴力。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int inline readint(){
int Num=,Flag=;char ch;
while((ch=getchar())<''||ch>'') if(ch=='-') break;
if(ch=='-') Flag=-; else Num=ch-'';
while((ch=getchar())>=''&&ch<='') Num=Num*+ch-'';
return Num*Flag;
}
struct DATA{
int num,idx;
bool tag;
}a[];
bool cmp1(const DATA &a,const DATA &b){
return a.num!=b.num?a.num<b.num:a.idx<b.idx;
}
bool cmp2(const DATA &a,const DATA &b){
return a.idx<b.idx;
}
int tmp[],cnt;
int main(){
int Test=readint();
while(Test--){
int N=readint();
for(int i=;i<=N;i++){
a[i].num=readint();
a[i].idx=i;
}
sort(a+,a++N,cmp1);
a[].tag=true;
for(int i=;i<=N;i++) a[i].tag=a[i-].num!=a[i].num;
sort(a+,a++N,cmp2);
cnt=;
for(int i=;i<=N;i++)
if(a[i].tag)
tmp[++cnt]=a[i].num;
for(int i=;i<cnt;i++) printf("%d ",tmp[i]);
printf("%d",tmp[cnt]);
if(Test>=) putchar('\n');
}
return ;
}
[BZOJ2761][JLOI2011]不重复数字 暴力的更多相关文章
- [BZOJ2761][JLOI2011]不重复数字
[BZOJ2761][JLOI2011]不重复数字 试题描述 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复 ...
- [BZOJ2761] [JLOI2011] 不重复数字 (C++ STL - set)
不重复数字 题目: 给出N个数,要求把其中重复的去掉,只保留第一次出现的数.例如,给出的数 为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 1 ...
- [BZOJ2761] [JLOI2011] 不重复数字 (set)
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- BZOJ2761:[JLOI2011]不重复数字(map)
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- BZOJ2761: [JLOI2011]不重复数字【set】【傻逼题】
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- bzoj2761: [JLOI2011]不重复数字(hash)
题目大意:给出N个数,要求把其中重复的去掉,只保留第一次出现的数.例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4. ...
- 【set】bzoj2761 [JLOI2011]不重复数字
set去重. #include<cstdio> #include<set> using namespace std; set<int>S; ],b[],en; in ...
- BZOJ 2761: [JLOI2011]不重复数字 水题
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2100 Solved: 809 题目连接 http:// ...
- bzoj 2761 [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 3210 Solved: 1186[Submit][Sta ...
随机推荐
- 北斗有 35 颗卫星,而 GPS 有 24 颗卫星,为什么二者数量不同?
作者:知乎用户链接:https://www.zhihu.com/question/21092045/answer/17164418来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...
- POJ3045 Cow Acrobats —— 思维证明
题目链接:http://poj.org/problem?id=3045 Cow Acrobats Time Limit: 1000MS Memory Limit: 65536K Total Sub ...
- [Selenium] 操作浏览器 Cookies
WebDriver 提供了一系列 Cookies 的操作来获取.填写.删除 Cookies 的方法,节省了多次在登陆页面的查找元素并填写登录信息的时间. 1)获取 Cookies ,并保存到文件中以备 ...
- Android开发中几种有用的的日历控件实现
我们大家都知道,在Android平台3.0中才新增了日历视图控件,可以显示网格状的日历内容,那么对于3.0以下的版本要使用日历控件只能借助第三方,目前用的最多的是CalendarView. 先简单介绍 ...
- bzoj5073
dp 字符串dp不太会啊... 这种序列和子串的匹配一般设两个状态,dp[i][j]表示当前s匹配到i,t匹配到j的...,g[i][j]表示当前s匹配到i,t匹配到j,i,j必须匹配的...,noi ...
- Linux ubuntu 下寻找 texlive 缺失包 texlive 缺失包(转载)
转自:http://blog.sina.com.cn/s/blog_87315ca60101d4d1.html 在Linux下用 latex 编译 ××.tex 文件有时候时会提示: ! LaTeX ...
- E20180426-hm
transition n. 过渡,转变,变迁; [语] 转换; [乐] 变调 flip vt. 按(开关); 快速翻转; 急挥; n. 空翻; 浏览; (射击时枪管的) 跳跃; 轻抛; win ...
- POJ1503
大数+++++ #include<cstdio> #include<string.h> #include<iostream> #include<algorit ...
- python 类对象和实例对象动态添加方法
class Person(): def __init__(self, name): self.name = name def print_name(self): print(self.name) p ...
- 两年Java程序员面试经验分享,从简历制作到面试总结!
前言 工作两年左右,实习一年左右,正式工作一年左右,其实挺尴尬的,高不成低不就.因此在面试许多公司,找到了目前最适合自己的公司之后.于是做一个关于面试的总结.希望能够给那些依旧在找工作的同学提供帮助. ...