题意:给你n个数,然后分成k部分,每一个部分的和为偶数的有p个,奇数的有k-p个,如果可以划分,输出其中的一种,不可以输出NO;

思路:先输出k-p-1个奇数,再输出p-1个偶数,剩余的在进行构造。  奇数+奇数=偶数。

 #include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#define maxn 1000100
#define ll long long
using namespace std; int n,k,p;
ll a[maxn];
vector<int>qq;
vector<int>pp; int main()
{
scanf("%d%d%d",&n,&k,&p);
for(int i=; i<=n; i++)
{
scanf("%lld",&a[i]);
if(a[i]%==) qq.push_back(a[i]);
else if(a[i]%!=) pp.push_back(a[i]);
}
int odd=pp.size();
int even=qq.size();
if(odd<k-p||(odd>=k-p&&even+(odd-(k-p))/<p)||(odd-(k-p))%==)
printf("NO\n");
else
{
printf("YES\n");
for(int i=; i<k-p-; i++)
{
printf("%d %d\n",,pp[i]);
}
int x=k-p-;
int y=even;
if(x<)x=;
for(int i=; i<p-; i++)
{
if(y)
{
printf("%d %d\n",,qq[y-]);
y--;
}
else
{
printf("%d %d %d\n",,pp[x],pp[x+]);
x+=;
}
}
if(k-p!=&&p)
{
printf("%d %d\n",,pp[x]);
x++;
}
if(x<) x=;
printf("%d ",y+odd-x);
while(y)
{
printf("%d ",qq[y-]);
y--;
}
while(x<odd)
{
printf("%d ",pp[x]);
x++;
}
printf("\n");
}
return ;
}

codeforces C. Devu and Partitioning of the Array的更多相关文章

  1. Codeforces 439C Devu and Partitioning of the Array(模拟)

    题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...

  2. codeforces 439D Devu and Partitioning of the Array(有深度的模拟)

    题目 //参考了网上的代码 注意答案可能超过32位 //要达成目标,就是要所有数列a的都比数列b的要小或者等于 //然后,要使最小的要和最大的一样大,就要移动(大-小)步, //要使较小的要和较大的一 ...

  3. codeforces 439C Devu and Partitioning of the Array(烦死人的多情况的模拟)

    题目 //这是一道有n多情况的烦死人的让我错了n遍的模拟题 #include<iostream> #include<algorithm> #include<stdio.h ...

  4. codeforces 251 div2 C. Devu and Partitioning of the Array 模拟

    C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...

  5. CodeForce 439C Devu and Partitioning of the Array(模拟)

     Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...

  6. CF 439C Devu and Partitioning of the Array

    题目链接: 传送门 Devu and Partitioning of the Array time limit per test:1 second     memory limit per test: ...

  7. CF 439C(251C题)Devu and Partitioning of the Array

    Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...

  8. Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Array

    注意p的边界情况,p为0,或者 p为k 奇数+偶数 = 奇数 奇数+奇数 = 偶数 #include <iostream> #include <vector> #include ...

  9. 【Henu ACM Round#20 D】 Devu and Partitioning of the Array

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 一开始所有的数字单独成一个集合. 然后用v[0]和v[1]记录集合的和为偶数和奇数的集合它们的根节点(并查集 然后先让v[0]的大小 ...

随机推荐

  1. BZOJ 3333 排队计划 树状数组+线段树

    题目大意:给定一个序列.每次选择一个位置,把这个位置之后全部小于等于这个数的数抽出来,排序,再插回去,求每次操作后的逆序对数 首先我们每一次操作 对于这个位置前面的数 因为排序的数与前面的数位置关系不 ...

  2. 最新Connectify注冊码(序列号) Connectify3.7序列号 破解版

    Connectify序列号.最新注冊码 今天给大家公布一个Connectify最新版的序列号(注冊码) 今天给大家公布一个Connectify最新版的序列号(注冊码) 经本人測试该注冊码为最新版Con ...

  3. 两层Fragment嵌套,外层Fragment切换时内层Fragment不显示内容

    尊重他人劳动成果,转载请说明出处:http://blog.csdn.net/bingospunky/article/details/46847269 需求 在搭界面有这么样一个需求:须要两层的Frag ...

  4. QDomDocument类

    QDomDocument类代表了一个XML文件 QDomDocument类代表整个的XML文件.概念上讲:它是文档树的根节点,并提供了文档数据的基本访问方法. 由于元素.文本节点.注释.指令执行等等不 ...

  5. 各种语言HMAC SHA256实现

    语言包含: Javascript ,PHP,Java,Groovy,C#,Objective C,Go,Ruby,Python,Perl,Dart,Swift,Rust,Powershell. Jav ...

  6. PHP 解决时差8小时的问题

    有时候用php echo date("Y-m-d H:i:s")的时候会发现自己的时间和系统时间有差别 这里问题一般就是因为你自己的时区和配置的时区出现了差别的原因: 解决办法有三 ...

  7. 关于c++中的引用

    引用是个别名. 1.引用是否占用空间 引用是否占用空间,此处是指广义上的占用内存空间,即为该对象新开辟一块内存.这个需要分不同的情况. 首先看一下常引用(const 引用). 这里关于常引用在c++  ...

  8. 我的C# - Web - DAL- DBHelper.cs

    其中的部分内容是别人的,我修改过了并加入了详细的注释!!! 一.这个DBHelper的大致块儿如下图: 二.下面是具体的源代码: //命名空间..... using System;using Syst ...

  9. Kettle的集群排序 2——(基于Windows)

    5.使用kettle集群模式对相关的数据进行排序 既然,基于Carte服务程序所搭建的集群已经在Spoon中设定好了, 可以首先,先来启动四个节点: "以管理员身份运行"打开 四个 ...

  10. switch语法之PHP

    $a = 100; switch ($a) { case 100: echo '满分'; break; case $a >=60: echo '及格'; break; }