Processing math: 100%
祝同学们学习进步,编程快乐!
Problem 2644 --Bitset II - Enumeration of Subsets II

2644: Bitset II - Enumeration of Subsets II

"
Time Limit 1 秒/Second(s) Memory Limit 512 兆字节/Megabyte(s)
提交总数 2 正确数量 2
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Enumeration of Subsets II

You are given a set T, which is a subset of U. The set U consists of 0, 1, ... n-1. Print all sets, each of which is a subset of U and includes T as a subset. Note that we represent 0, 1, ... n-1 as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a subset is calculated by bitwise OR of existing elements.

The input is given in the following format.

nn kb0b1...bk1kb0b1...bk−1 

kk is the number of elements in TT, and bibi represents elements in TT.

Output

Print the subsets ordered by their decimal integers. Print a subset in the following format.

dd: e0e0 e1e1 ...

Print ':' after the integer value dd, then print elements eiei in the subset in ascending order. Separate two adjacency elements by a space character.

4
2 0 2
5: 0 2
7: 0 1 2
13: 0 2 3
15: 0 1 2 3

Constraints

  • 1n181≤n≤18
  • 0kn0≤k≤n
  • 0bi<n0≤bi<n


推荐代码 查看2644 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[45 ms] AOJ大管家 437041 2019-06-07 13:08:18
内存最少[0 KB] Qiqy 609179 2020-08-02 13:55:03
第一AC AOJ大管家 437041 2019-06-07 13:08:18
第一挑战 AOJ大管家 437041 2019-06-07 13:08:18

赛题来源/所属竞赛 会津大学《C++ Programming II》 C++程序设计(高级)

竞赛编号 竞赛名称 竞赛时间 访问比赛
AOJ
祝同学们学习进步,编程快乐!