题目

//这是一道有n多情况的烦死人的让我错了n遍的模拟题

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std; int a[],n,k,p;
int vis[];
int ji=,ou=; int main()
{
memset(vis,,sizeof(vis));
cin >> n >> k >> p;
for(int i=;i<n;i++)
{
cin >> a[i];
if(a[i]%==)
ji++;
else ou++;
}
if((ji-(k-p))%==||ji<k-p||((ji-(k-p))/+ou<p))
printf("NO\n");
else
{
printf("YES\n");
int odd=,even=,al=;
if(p!=)
{
for(int i=;i<n;i++)
{
if(a[i]%)
{
if(odd<k-p)
{
printf("1 %d\n",a[i]);
odd++;
vis[i]=;
al++;
}
else break;
}
} for(int i=;i<n;i++)
{
if(a[i]%==)
{
if(even<p-)
{
printf("1 %d\n",a[i]);
even++;
vis[i]=;
al++;
}
else break;
}
}
int flag=;
for(int i=;i<n;i++)
{
if(even<p-)
{
if(vis[i]==&&a[i]%==&&flag==)
printf("2 %d",a[i]),flag=,vis[i]=,al++;
else if(vis[i]==&&a[i]%==&&flag==)
printf(" %d\n",a[i]),flag=,vis[i]=,even++,al++;
}
else break;
}
if(n-al>)
{
cout << n-al;
for(int i=;i<n;i++)
{
if(vis[i]==)
printf(" %d",a[i]);
}
} }
else
{
for(int i=;i<n;i++)
{
if(a[i]%)
{
if(odd<k-p-)
{
printf("1 %d\n",a[i]);
odd++;
vis[i]=;
al++;
}
else break;
}
}
if(n-al>)
{
cout << n-al;
for(int i=;i<n;i++)
{
if(vis[i]==)
printf(" %d",a[i]);
}
} }
puts("");
}
return ;
}

codeforces 439C 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. 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 ...

  3. CF 439C Devu and Partitioning of the Array

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

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

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

  5. codeforces C. Devu and Partitioning of the Array

    题意:给你n个数,然后分成k部分,每一个部分的和为偶数的有p个,奇数的有k-p个,如果可以划分,输出其中的一种,不可以输出NO; 思路:先输出k-p-1个奇数,再输出p-1个偶数,剩余的在进行构造.  ...

  6. 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 ...

  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. poj 2507Crossed ladders <计算几何>

    链接:http://poj.org/problem?id=2507 题意:哪个直角三角形,一直角边重合, 斜边分别为 X, Y, 两斜边交点高为 C , 求重合的直角边长度~ 思路: 设两个三角形不重 ...

  2. spring 基本操作总结主要是aop以及依赖注入的基本配置

    一所需架包 spring commom-logging.jar  spring.jar 注解 common-annotation.jar aop面向切面 aspectjrt.jar    aspect ...

  3. SQLite数据库与Contentprovider(1)

    SQlite:类似mysql的数据库.把数据保存到.db文件夹中. Contentprovider:一般用于不同进程之间的数据共享(两个APP). 手动建库:http://www.runoob.com ...

  4. hdu 1042 N!

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1042 N! Description Given an integer N(0 ≤ N ≤ 10000) ...

  5. 十一、从头到尾彻底解析Hash 表算法

    在研究MonetDB时深入的学习了hash算法,看了作者的文章很有感触,所以转发,希望能够使更多人受益! 十一.从头到尾彻底解析Hash 表算法 作者:July.wuliming.pkuoliver  ...

  6. php匿名函数小示例

    <?php //$fun = function($params){ // echo $params; //}; // //$fun('aa'); //例一 //在普通函数中定义一个匿名函数 // ...

  7. 【转】linux root用户ifconfig报command not found

    解决办法: 方法一: 直接输入su - 回车.就可以ifconfig了 方法二: /etc/profile 把下面if语句注释掉: #path Manipulation if ["EUID& ...

  8. Daily Scrum1--团队项目分工及估计时间

    团队项目分工及估计时间 PM(黄剑锟): 任务一:监督进度,将每一天完成的任务总结,在各个部分进行协调与帮助.(贯穿整个项目周期) 任务二:提高搜索反应时间,优化搜索算法.(估计时间8小时) 程序设计 ...

  9. 新 四则运算题目 C++

    源代码: #include <stdlib.h>#include <iostream.h>#include <conio.h>#include <time.h ...

  10. 找出1-N中1的个数

    一.题目 给定一个十进制的正整数,写下从1开始,到N的所有整数,然后数一下其中出现“1”的个数. 要求: 写一个函数 f(N) ,返回1 到 N 之间出现的 “1”的个数.例如 f(12)  = 5. ...