UVA 1623(p256)----Enter the Dragon
来源:互联网 发布:everest硬件检测软件 编辑:程序博客网 时间:2024/04/27 21:39
#include<iostream>#include<cstdio>#include<set>#include<cstring>using namespace std;const int maxn=1e6+50;int lake,n;int a[maxn];int ans[maxn];int have[maxn];set<int> s;int main(){ int t; scanf("%d",&t); while(t--) { int flag=1; s.clear(); memset(ans,0,sizeof(ans)); memset(have,0,sizeof(have)); scanf("%d%d",&lake,&n); for(int i=0; i<n; i++) { int x; scanf("%d",&x); a[i]=x; if(!x) s.insert(i); else { set<int>::iterator it=s.lower_bound(have[x]); if(it==s.end()) flag=0; ans[*it]=x; have[x]=i; s.erase(*it); } } if(!flag) printf("NO\n"); else { printf("YES\n"); for(int i=0; i<n-1; i++) if(a[i]==0) printf("%d ",ans[i]); if(a[n-1]==0&&ans[n-1]>=0) printf("%d",ans[n-1]); printf("\n"); } } return 0;}
0 0
- UVA 1623(p256)----Enter the Dragon
- UVa 1623 Enter The Dragon
- UVa - 1623 - Enter The Dragon
- uva 1623 - Enter The Dragon
- UVA - 1623 - Enter The Dragon
- UVa 1623 - Enter The Dragon(贪心)
- UVa 1623:Enter the Dragon(贪心)
- uva 1623——Enter The Dragon
- 1623-Enter the Dragon【贪心】
- UVA 1312(p256)----Cricket Field
- UVA 1619(p256)----Feel Good
- UVa 11292 - The Dragon of Loowater
- UVa 11292 The Dragon of Loowater
- UVA 11292 - The Dragon of Loowater (water)
- uva 11929The Dragon of Loowater
- uva 11292 The Dragon of Loowater
- UVA 11292 The Dragon of 贪心
- UVA 11292 The Dragon of Loowater
- OpenGL ES 三种类型修饰 uniform attribute varying
- UVA 1619(p256)----Feel Good
- bzoj1864 三色二叉树 树形dp
- Android学习资源网站大全
- 传统RAID重构过程中的磁盘损坏
- UVA 1623(p256)----Enter the Dragon
- android 一行代码,快速实现图片验证码(附android studio 版小demo)
- Hibernate之使用sql语句查询多个表,返回多种字段,将返回结果映射到自定义的普通pojo类中
- Java中命名规则及基本数据类型的长度、表示范围
- Android 开源项目分类汇总
- 机器学习之K-近邻算法(kNN算法)
- TCP首部格式
- 使用MongoDB的MapReduce进行区域地震信息统计实验
- C#单例模式的三种写法