codeforces 439C Devu and Partitioning of the Array(烦死人的多情况的模拟)
//这是一道有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(烦死人的多情况的模拟)的更多相关文章
- Codeforces 439C Devu and Partitioning of the Array(模拟)
题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...
- 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 ...
- CF 439C Devu and Partitioning of the Array
题目链接: 传送门 Devu and Partitioning of the Array time limit per test:1 second memory limit per test: ...
- codeforces 439D Devu and Partitioning of the Array(有深度的模拟)
题目 //参考了网上的代码 注意答案可能超过32位 //要达成目标,就是要所有数列a的都比数列b的要小或者等于 //然后,要使最小的要和最大的一样大,就要移动(大-小)步, //要使较小的要和较大的一 ...
- codeforces C. Devu and Partitioning of the Array
题意:给你n个数,然后分成k部分,每一个部分的和为偶数的有p个,奇数的有k-p个,如果可以划分,输出其中的一种,不可以输出NO; 思路:先输出k-p-1个奇数,再输出p-1个偶数,剩余的在进行构造. ...
- 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 ...
- 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 ...
- Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Array
注意p的边界情况,p为0,或者 p为k 奇数+偶数 = 奇数 奇数+奇数 = 偶数 #include <iostream> #include <vector> #include ...
- 【Henu ACM Round#20 D】 Devu and Partitioning of the Array
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 一开始所有的数字单独成一个集合. 然后用v[0]和v[1]记录集合的和为偶数和奇数的集合它们的根节点(并查集 然后先让v[0]的大小 ...
随机推荐
- SoundCloud 的开发功能
SoundCloud开发功能:https://developers.soundcloud.com/docs 来自为知笔记(Wiz)
- Android 创建单例模式的几种方法
java模式之单例模式:单例模式确保一个类只有一个实例,自行提供这个实例并向整个系统提供这个实例.特点:1,一个类只能有一个实例2,自己创建这个实例3,整个系统都要使用这个实例 Singleton模式 ...
- centos6.5适用的国内yum源:网易、搜狐
设置方法如下: 1,进入yum源配置目录cd /etc/yum.repos.d 2,备份系统自带的yum源mv CentOS-Base.repo CentOS-Base.repo.bak 下载163网 ...
- MVC 局部加载页面的实例
我们在做MVC 进行某一块的局部刷新,有的使用AJAX 请求,有的使用局部页: 下面我给大家推荐一种使用局部页面实现的这种方式: 第一步: 嵌套视图页 <div id="showAud ...
- [转]Reed Solomon纠删码
[转]Reed Solomon纠删码 http://peterylh.blog.163.com/blog/static/12033201371375050233/ 纠删码是存储领域常用的 ...
- 33.allegro中Autosilk top, Silkscreen top 和Assembly top三个什么区别(转)
Autosilk top, Silkscreen top 和Assembly top Autosilk top:最后出gerber的时候,自动生成的丝印层.会自动调整丝印位置,以及碰到阻焊开窗的地方, ...
- Zybo智能小车识别图像中的文字
智能小车识别图像中的文字 [TOC] 运行平台 这次的内容是基于Xilinx公司的Zybo开发板以及其配套的Zrobot套件开发 Zybo上面的sd卡搭载了Ubuntu12.04LTS的linux版本 ...
- [rsync]——rsync文件同步和备份
实验环境 (1) Rsync服务器:10.0.10.158 (2) Rsync客户端:10.0.10.173 Rsync服务器端的配置 1. 安装xinetd和rsync # yum install ...
- 64位Windows2003下如何正确发布VesnData.Net(VDN)
64位windows2003下发布VDN,按照正常的步骤会出现:试图加载格式不正确的程序. (异常来自 HRESULT:0x8007000B)的错误. 按照下面的步骤进行处理: 1.如果安装了64位F ...
- 字符串流sstream[part3/使用字符串流进行安全的类型转换]
参考: http://blog.163.com/zhuandi_h/blog/static/180270288201291710222975/ http://www.cnblogs.com/games ...