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]的大小 ...
随机推荐
- Swing基础
Swing基础 JFrame JPanel 绘图:paint 监听事件: ActionListener KeyListener Listener和Adapter 计时器:Timer Time ...
- Percona-Xtrabackup 2.3.3 慢查询不再堵塞备份(一)
在Percona-Xtrabackup 2.3.3[root@b28-19-17 bak]# rpm -q percona-xtrabackuppercona-xtrabackup-2.3.3-1.e ...
- 安装Oracle11g时,检测到系统的主 IP 地址是 DHCP 分配的地址
检查完成.此次检查的总体结果为: 失败 <<<< 问题: 安装检测到系统的主 IP 地址是 DHCP 分配的地址. 建议案: Oracle 支持在具有 DHCP 分配的 IP ...
- 九度oj 1407 快速找出最小数
原题链接:http://ac.jobdu.com/problem.php?pid=1407 线段树,区间更新,查询区间最小值. 注意区间更新,查询的时候,区间$\begin{align*}[L,R] ...
- linux 禁止指定账号ssh登陆
1 2 3 4 vim /etc/pam.d/sshd #在第一行添加以下代码 auth required pam_listfile.so item=user sense=de ...
- mac os x 系统安装 genymotion android 模拟器
如果你有 apk 文件 想 运行一下看看 ,但是又没有 android 设备 ,那么 genymotion 将会是一个 很好的解决方案. 1.安装 下载链接: https://cloud.geny ...
- Swift TabeleViewCell dequeueReusableCellWithIdentifier 使用的新的细节,原来现在可以这样
今天在看官方的TableView Guide,突然想起来最近写的一个代码中实现tableViewCell复用的时候有点问题: var cell = UITableViewCell(style: UIT ...
- 如何在Window上使用Git
开始的时候同事只给了一个地址,类似这样:git@111.111.1.1:ABCDEF (1)如何在Windows上使用Git 有一篇博客不错:http://www.tuicool.com/articl ...
- Android实现SharePreferences和AutoCompletedTextView
Android实现SharePreferences和AutoCompletedTextView 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 ...
- js之Function原型
在ECMAScript中,Function(函数)类型实际上是对象.每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此函数名实际上也是一个指向函数对象 ...