Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Array
注意p的边界情况,p为0,或者 p为k
奇数+偶数 = 奇数
奇数+奇数 = 偶数
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath> using namespace std; int main(){
int n,k,p;
long a;
cin >> n >> k >> p;
vector<long> even, odd;
vector<set<long> > parts(k);
for(int i = ; i < n ; ++ i){
cin >> a;
a% ? odd.push_back(a): even.push_back(a);
}
int even_cnt = p, odd_cnt = k - p;
if(odd.size() < odd_cnt || (odd.size() -odd_cnt)% ) cout<<"NO"<<endl;
else{
for(int i = p; i < k ; ++ i) parts[i].insert(odd[i-p]);
if(even.size()+(odd.size()-odd_cnt)/ < p) cout<<"NO"<<endl;
else{
if(even.size() >= p){
for(int i = ; i < p; ++ i) parts[i].insert(even[i]);
for(int i = p; i < even.size(); ++ i) parts[p- >= ? p- : p].insert(even[i]);
for(int i = k-p; i < odd.size() ; ++ i ) parts[p- >= ? p- : p].insert(odd[i]); }else{
for(int i = ; i < even.size(); ++ i) parts[i].insert(even[i]);
int j = k-p;
for(int i = even.size(); i < p-; ++ i) parts[i].insert(odd[j++]),parts[i].insert(odd[j++]);
while( j < odd.size()) parts[p- >= ? p- : p].insert(odd[j++]);
}
cout<<"YES"<<endl;
for(int i = ; i < k; ++ i){
set<long> tmp = parts[i];
cout<<tmp.size();
for(set<long>::iterator iter = tmp.begin(); iter!=tmp.end(); ++ iter) cout<<" "<<*iter;
cout<<endl;
}
}
}
}
Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Array的更多相关文章
- Codeforces Round#251(Div 2)D Devu and his Brother
--你以为你以为的.就是你以为的? --有时候还真是 题目链接:http://codeforces.com/contest/439/problem/D 题意大概就是要求第一个数组的最小值要不小于第二个 ...
- Codeforces Round #251 (Div. 2) B. Devu, the Dumb Guy
注意数据范围即可 #include <iostream> #include <vector> #include <algorithm> using namespac ...
- Codeforces Round #251 (Div. 2) A - Devu, the Singer and Churu, the Joker
水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...
- Codeforces Round 251 (Div. 2)
layout: post title: Codeforces Round 251 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Codeforces Round #258 (Div. 2) E. Devu and Flowers 容斥
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to deco ...
- Codeforces Round #258 (Div. 2)E - Devu and Flowers
题意:n<20个箱子,每个里面有fi朵颜色相同的花,不同箱子里的花颜色不同,要求取出s朵花,问方案数 题解:假设不考虑箱子的数量限制,隔板法可得方案数是c(s+n-1,n-1),当某个箱子里的数 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- SQL exists( select 1 from
use UnlockIndustry select * from Info_Coordinate as A join Info_Employee on A.EmployeeId=Info_Employ ...
- Cube Processing Options
在 Microsoft SQL Server Analysis Services 中处理对象时,您可以选择处理选项以控制每个对象的处理类型. 处理类型因对象而异,并基于自上次处理对象后对象所发生的更 ...
- hdu 4751 2013南京赛区网络赛 二分图判断 **
和以前做过的一个二分图颇为相似,以前的是互相不认识的放在一组,这个是互相认识的,本质上是相同的 是 hdu 2444 #include<cstdio> #include<iostre ...
- Mysql数据库操作系统及配置参数优化
数据库结构优化 表的水平拆分常用的水平拆分方法为:1.对 customer_id进行 hash运算,如果要拆分成5个表 则使用mod(customer_id,5)取出0-4个值2.针对不同的 hash ...
- 谈谈网站插入youtube视频播放
最近需要在网页首页追加视频播放功能. 需要播放youtube视频.中间遇到一些波折.特来分享一下. 首先像网页添加视频文件我们通常够采用embed标签. 标签里可以设置很多的关键子.我们可以配置为fl ...
- Android三种基本的加载网络图片方式(转)
Android三种基本的加载网络图片方式,包括普通加载网络方式.用ImageLoader加载图片.用Volley加载图片. 1. [代码]普通加载网络方式 ? 1 2 3 4 5 6 7 8 9 10 ...
- JNI数据类型(转)
本文原创,转载请注明出处:http://blog.csdn.net/qinjuning 在Java存在两种数据类型: 基本类型 和 引用类型 ,大家都懂的 . 在JNI的世界里也存在类似的数据类型,与 ...
- java学习笔记(2):获取文件名和自定义文件过滤器
//自定义文件过滤器import java.io.File; import javax.swing.filechooser.*; public class JavaChooser extends Fi ...
- 主流IM协议简介
四种主流的IM协议, XMPP协议.即时信息和空间协议(IMPP).空间和即时信息协议(PRIM).针对即时通讯和空间平衡扩充的进程开始协议SIP(SIMPLE). XMPP协议: 在这四种协议中,X ...
- windows下mongodb安装与使用整理
一.首先安装mongodb 1.下载地址:http://www.mongodb.org/downloads 2.解压缩到自己想要安装的目录,比如d:\mongodb 3.创建文件夹d:\mongodb ...