Codeforces 439C Devu and Partitioning of the Array
来源:互联网 发布:网络红包潮阅读答案 编辑:程序博客网 时间:2024/06/05 09:44
题目连接:Codeforces 439C Devu and Partitioning of the Array
比较坑一题,很多细节需要把握。
奇数只能由奇数个奇数组成,那让奇数组全由一个奇数组成(除了某些情况,比如p = 0),然后就是各种细节各种判断了。
#include <iostream>#include <cstdio>#include <vector>using namespace std;vector <__int64> even, odd;int main(){ __int64 n, k, p, temp; scanf("%I64d%I64d%I64d", &n, &k, &p); for(int i = 0; i < n; i++) { scanf("%I64d", &temp); if(temp % 2 == 0) even.push_back(temp); else odd.push_back(temp); } __int64 _size_odd = odd.size(), _size_even = even.size(), i = 0, j = 0, remain, all; if(_size_odd < k - p || (_size_odd - (k - p)) % 2 != 0 || ((_size_odd - (k - p)) / 2) + _size_even < p) puts("NO"); else { puts("YES"); if(p == 0) { while(i < (k - p) - 1) printf("1 %I64d\n", odd[i++]); remain = _size_odd - i + _size_even; printf("%d", remain); while(i < _size_odd) printf(" %d", odd[i++]); while(j < _size_even) printf(" %d", even[j++]); puts(""); } else while(i < (k - p)) printf("1 %I64d\n", odd[i++]); if(p != 0) { while(true) { remain = p--; if(remain == 1) { all = _size_even - j + _size_odd - i; printf("%I64d", all); while(j < _size_even) printf(" %I64d", even[j++]); while(i < _size_odd) printf(" %I64d", odd[i++]); puts(""); break; } else { if(j < _size_even) printf("1 %I64d\n", even[j++]); else printf("2 %I64d %I64d\n", odd[i++], odd[i++]); } } } } return 0;}
0 0
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array(模拟)
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array 模拟
- C. Devu and Partitioning of the Array
- CodeForce 439C Devu and Partitioning of the Array(模拟)
- codeforces 439C Devu and Partitioning of the Array(简单题)
- Codeforces Round #251 (Div. 2) 439C Devu and Partitioning of the Array(脑洞)
- Codeforces Round #251(Div. 2) 439C. Devu and Partitioning of the Array 构造
- Codeforces 439C Devu and Partitioning of the Array【大力讨论】
- Codeforces Round #251 (Div. 2) C Devu and Partitioning of the Array
- CF 439C(251C题)Devu and Partitioning of the Array
- CodeForce 439C Devu and Partitioning of the Array(模拟)
- Codeforces 439A Devu, the Singer and Churu, the Joker
- Codeforces 439 A. Devu, the Singer and Churu, the Joker
- Codeforces 439A Devu, the Singer and Churu, the Joker
- codeforces 439A Devu, the Singer and Churu, the Joker
- C和指针 学习笔记-1.编译与链接
- 青蛙的约会
- 带权二分图最佳匹配KM算法模板
- 华为OJ_1950_句子逆序
- java JSP EL表达式
- Codeforces 439C Devu and Partitioning of the Array
- qt 调用dll
- 一个基于src和ashx的无刷新下载文件和更新图片的方法
- 云计算
- C和指针 学习笔记-2.指针
- 不看代码粗略了解TLD
- FFmpeg音视频同步的问题
- 冒泡排序&选择排序(c 语言函数版)
- SQLServer恢复表级数据