bzoj 2761 题解
来源:互联网 发布:编程猫的网址 编辑:程序博客网 时间:2024/05/16 01:51
cgh的水题.
两次sort出结果
Code:
/************************************************************** Problem: 2761 User: wohenshuai Language: C++ Result: Accepted Time:1064 ms Memory:9948 kb****************************************************************/ #include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<cstdlib>#include<algorithm>using namespace std;struct node{ int x,id;}a[1110000];bool Cmp1(node x,node y){ if(x.x!=y.x) return x.x<y.x; else return x.id<y.id;}bool Cmp2(node x,node y){ return x.id<y.id;}int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i].x); a[i].id=i; } sort(a+1,a+n+1,Cmp1); for(int i=1;i<=n;i++) { if(a[i].x==a[i+1].x) a[i+1].id=-1; } sort(a+1,a+n+1,Cmp2); int tim=0; for(int i=1;i<=n;i++) { if(a[i].id!=-1&&tim==0) { printf("%d",a[i].x); tim=1; } else if(a[i].id!=-1) printf(" %d",a[i].x); } printf("\n"); } return 0;}
0 0
- bzoj 2761 题解
- bzoj题解
- [bzoj-2761][JLOI2011]不重复数字 题解
- bzoj 1218题解
- bzoj 2456 mode 题解
- bzoj 2506 calc 题解
- BZOJ 1257 (题解)
- bzoj 1003 题解
- bzoj 1053 题解
- bzoj 2464 题解
- bzoj 1085 题解
- bzoj 2464 题解
- bzoj 1045 题解
- bzoj 1059 题解
- bzoj 1054 题解
- bzoj 1050 题解
- bzoj 1047 题解
- bzoj 1083 题解
- linux期末复习知识点小结(一)——Introduction
- 设计模式(五)适配器
- 【Jenkins系列之一】Jenkins持续集成环境搭建完全指南
- MFC中获取各个窗口(对话框)之间的指针、对象、句柄
- Caching Bitmaps
- bzoj 2761 题解
- Domino Calendar REST API性能调优 之 代码篇
- Android中试调程序debug
- GPT分区数据格式分析(图已补上)
- Managing Bitmap Memory
- 富文本编辑
- 《征服C指针》读后笔记
- Displaying Bitmaps in Your UI
- myeclispe 中deploy时不能出现deploy location?