大水题。。

求集合的并

 /*

 */
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int inf = 0x3f3f3f3f;
const double pi=acos(-1.0);
const int dx[]={,-,,};
const int dy[]={,,,-};
const double eps = 1e-;
const int maxm = ;
const int maxn = ; int a[ maxn ],b[ maxn ]; int main(){
int n,m;
while( scanf("%d%d",&n,&m)== ){
for( int i=;i<n;i++ ){
scanf("%d",&a[i]);
}
for( int i=;i<m;i++ ){
scanf("%d",&b[i]);
}
sort( a,a+n );
sort( b,b+m );
int cur = -;
int ai = ;
int bi = ;
while( ai<n || bi<m ){
if( ai==n ){
for( int i=bi;i<m;i++ ){
if( b[ i ]==cur ) continue;
else {
cur = b[ i ];
printf(" %d",cur);
}
}
break;
}
if( bi==m ){
for( int i=ai;i<n;i++ ){
if( a[ i ]==cur ) continue;
else {
cur = a[ i ];
printf(" %d",cur);
}
}
break;
}
if( cur==- ){
if( a[ai]<b[bi] ){
cur = a[ ai ];
ai ++;
}
else if( a[ai]==b[bi] ){
cur = a[ ai ];
ai ++;
bi ++;
}
else {
cur = b[ bi ];
bi ++;
}
printf("%d",cur);
}
else {
if( a[ai]<b[bi]&&a[ai]>cur ){
cur = a[ ai ];
ai ++;
printf(" %d",cur);
}
else if( a[ai]==b[bi]&&a[ai]>cur ){
cur = a[ ai ];
ai ++;
bi ++;
printf(" %d",cur);
}
else if( a[ai]>b[bi]&&b[bi]>cur ){
cur = b[bi];
bi ++;
printf(" %d",cur);
}
}
}
printf("\n");
}
return ;
}

HDU1412的更多相关文章

  1. (Set){A} + {B} hdu1412

    {A} + {B} 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1412   Problem Description 给你两个集合,要求{A} + {B} ...

  2. HDU1412:{A} + {B}

    Problem Description 给你两个集合,要求{A} + {B}. 注:同一个集合中不会有两个相同的元素.   Input 每组输入数据分为三行,第一行有两个数字n,m(0<n,m& ...

  3. STL应用——hdu1412(set)

    set函数的应用 超级水题 #include <iostream> #include <cstdio> #include <algorithm> #include ...

  4. HDU1412 {A} + {B}

    2019-05-17 10:15:01 每个元素之间有一个空格隔开. 每行最后一的元素后面没有空格,区别于HDU人见人爱A - B 注意使用STL的时候要清空 .  a.clear(); #inclu ...

  5. OJ题目分类

    POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...

  6. STL使用————SET&MULTISET

    SET函数的基本用法 by hhl 使用set的好处 1. 当增加元素后,集合会自动删重并从小到大排列(时间比快排还快)2. 相当于一棵伸展树(能快速求出后继) 使用基础 #include<se ...

随机推荐

  1. 什么是C++标准库?

    C++中的标准程序库(简称标准库)是类库和函数的集合,其使用核心语言写成.标准程序库提供若干泛型容器.函数对象.泛型字符串和流(包含交互和文件I/O),支持部分语言特性和常用的函数,如开平方根.C++ ...

  2. 在WCF中使用Flag Enumerations

      请看MSDN示例: [DataContract][Flags] public enum CarFeatures {     None = 0,     [EnumMember]     AirCo ...

  3. Eclipse 调试maven test

    在eclipse中调试maven test 一般情况下,使用如下方式都不能使myeclipse检测到程序中的断点: 项目 -> Run As -> maven test 或 项目 -> ...

  4. 关于arcgis发布wfs问题

    博客地址http://www.cnblogs.com/shizhongtao/p/3453594.html 官方文档中有这么一段描述: 从地图创建 WFS 服务 您 可以从 ArcMap 地图文档 ( ...

  5. apache 设置禁止访问某些文件或目录

    [apache配置禁止访问]1. 禁止访问某些文件/目录增加Files选项来控制,比如要不允许访问 .inc 扩展名的文件,保护php类库:<Files ~ "\.inc$" ...

  6. php 实现 mysql数据表优化与修复

    <?php $link = mysql_connect("localhost", "root", "") or die("e ...

  7. DataGridView 分页显示

    DataGridView 分页显示函数 1.获取当前页的子数据表函数 public static DataTable GetPagedTable(DataTable dt, int PageIndex ...

  8. 修改zepto源代码,使支持wp8的ie10

    注意:当前1.1.3版本的zepto,已经有模块来支持wp8 原先的zepto,通过__proto__赋值,来使dom继承到$.fn方法, 无奈IE11之前的IE10,IE9不支持这种写法, 所以我们 ...

  9. JAVASCRIPT实现翻页保存已勾选的项目

    <input type="checkbox" name="a" value="1" /><br/> <inpu ...

  10. html 元素添加 class

    <!-- 给 input 添加 class 一个input 可以添加多个class 中间空格隔开. --> @Html.TextBox("txtIDNumber", & ...