[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 ...
随机推荐
- Parallels Desktop 设置win网络连接
目的: 1 虚拟机中的win系统技能访问外网 2 可以和Mac系统互联 首先来实现1,很简单: 打开控制中心对应系统的设置 选择[硬件]->[网络] 源:设置共享网络 到此就达到1目的了: 现在 ...
- (linux)wake_lock机制
Android的休眠唤醒主要基于wake_lock机制,只要系统中存在任一有效的wake_lock,系统就不能进入深度休眠,但可以进行设备的浅度休眠操作.wake_lock一般在关闭lcd.tp但 ...
- elasticsearch索引查询,日志搜素
索引查询 http://10.199.137.115:9200/_cat/indices?format=json 返回json字符串的索引状态 增加索引名称过滤 http://10.199.137.1 ...
- [arm驱动]Linux内核开发之阻塞非阻塞IO----轮询操作【转】
本文转载自:http://7071976.blog.51cto.com/7061976/1392082 <[arm驱动]Linux内核开发之阻塞非阻塞IO----轮询操作>涉及内核驱动函数 ...
- 倒排列表求交集算法 包括baeza yates的交集算法
#ifndef __INTERSECT_HPP__ #define __INTERSECT_HPP__ #include "probe.hpp" namespace themas ...
- Android自动化测试环境搭建
Android自动化环境的搭建主要包括: 1. java jdk和jre的安装和环境的配置 2. appium服务器的安装和配置 3. eclipse开发工具,这里不必要用Android Studio ...
- linux防火墙过滤规则
一.linux防火墙基础 防火墙分为硬件防火墙和软件防火墙. 1.概述 linux 防火墙体系主要工作在网络层,针对TCP/IP数据包实施过滤和限制,属于典型的包过滤防火墙. 包过滤机制:netfil ...
- 《算法概论》第八章的一些课后题目 关于NP-Complete Problem
8.3 STINGY SAT STINGY SAT is the following problem: given a set of clauses (each a disjunction of li ...
- 模板 - 字符串 - Manacher
求最长回文子串. #include<bits/stdc++.h> using namespace std; #define ll long long ; ]; ]; int Manache ...
- POJ3616【基础DP】
//因为同一点结束的时间段会有多个,这里没考虑: //无限wa: const int N=1e6+7; int b[N]; LL a[N]; LL dp[N]; struct asd{ int s; ...