注意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的更多相关文章

  1. Codeforces Round#251(Div 2)D Devu and his Brother

    --你以为你以为的.就是你以为的? --有时候还真是 题目链接:http://codeforces.com/contest/439/problem/D 题意大概就是要求第一个数组的最小值要不小于第二个 ...

  2. Codeforces Round #251 (Div. 2) B. Devu, the Dumb Guy

    注意数据范围即可 #include <iostream> #include <vector> #include <algorithm> using namespac ...

  3. Codeforces Round #251 (Div. 2) A - Devu, the Singer and Churu, the Joker

    水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...

  4. Codeforces Round 251 (Div. 2)

    layout: post title: Codeforces Round 251 (Div. 2) author: "luowentaoaa" catalog: true tags ...

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

  6. Codeforces Round #258 (Div. 2)E - Devu and Flowers

    题意:n<20个箱子,每个里面有fi朵颜色相同的花,不同箱子里的花颜色不同,要求取出s朵花,问方案数 题解:假设不考虑箱子的数量限制,隔板法可得方案数是c(s+n-1,n-1),当某个箱子里的数 ...

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

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. 数据结构和算法 – 3.堆栈和队列

    1.栈的实现   后进先出     自己实现栈的代码 using System; using System.Collections.Generic; using System.Linq; using ...

  2. JustSniffer

    http://blog.csdn.net/cnbird2008/article/details/5875781

  3. 排队打饭 sdut 2443【最简单的贪心法应用举例】

    排队打饭 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...

  4. slf4i + logback 配置

    一.所需jar包: slf4j-api-1.6.1.jar logback-classic-0.9.24.jar logback-core-0.9.24.jar 二.logback.xml配置示例: ...

  5. RMAN恢复目录

    是否使用RMAN恢复目录(Recovery Catalog 你可能从其他人或书上听过RMAN恢复目录(也有可能是其他名字,RMAN Recovery Catalog的翻译较多较杂,以下简称恢复目录), ...

  6. 11g新特性-概述 (转)

    一.新特性提纲 1.数据库管理部分 ◆数据库重演(Database Replay) 这一特性可以捕捉整个数据的负载,并且传递到一个从备份或者standby数据库中创建的测试数据库上,然后重演负责以测试 ...

  7. PAT A 1013. Battle Over Cities (25)【并查集】

    https://www.patest.cn/contests/pat-a-practise/1013 思路:并查集合并 #include<set> #include<map> ...

  8. pythonchallenge之C++学习篇-00

    前言 最近学习下C++,之前是python的用户,python解释器有诸多实现,其中最出名的要数C实现了,而且很多python的扩展模块可能要用C或者C++来写的,所以很有必要学习下C++了 为了避免 ...

  9. 数据分析(3):ufunc

    universal function 可以对数组里的每一个元素进行操作,底层是C语言实现的,在对数组运算时表现卓越 1.1 初步上手 x = np.linspace(0,2*np.pi,10) y = ...

  10. unable to access android sdk add-on list

    在bin\properties里添加disable.android.first.run=true