A9093 | Xenia and Weights
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes on the left scalepan, the fourth one goes on the right scalepan and so on. Xenia wants to put the total of $m$ weights on the scalepans.
Simply putting weights on the scales is not interesting, so Xenia has set some rules. First, she does not put on the scales two consecutive weights of the same weight. That is, the weight that goes $i$ -th should be different from the $(i+1)$ -th weight for any $i$ $(1<=i<m)$ . Second, every time Xenia puts a weight on some scalepan, she wants this scalepan to outweigh the other one. That is, the sum of the weights on the corresponding scalepan must be strictly greater than the sum on the other pan.
You are given all types of weights available for Xenia. You can assume that the girl has an infinite number of weights of each specified type. Your task is to help Xenia lay $m$ weights on the scales or to say that it can't be done.
Simply putting weights on the scales is not interesting, so Xenia has set some rules. First, she does not put on the scales two consecutive weights of the same weight. That is, the weight that goes $i$ -th should be different from the $(i+1)$ -th weight for any $i$ $(1<=i<m)$ . Second, every time Xenia puts a weight on some scalepan, she wants this scalepan to outweigh the other one. That is, the sum of the weights on the corresponding scalepan must be strictly greater than the sum on the other pan.
You are given all types of weights available for Xenia. You can assume that the girl has an infinite number of weights of each specified type. Your task is to help Xenia lay $m$ weights on the scales or to say that it can't be done.
输入格式
The first line contains a string consisting of exactly ten zeroes and ones: the $i$ -th $(i>=1)$ character in the line equals "1" if Xenia has $i$ kilo weights, otherwise the character equals "0". The second line contains integer $m$ $(1<=m<=1000)$ .
输出格式
In the first line print "YES", if there is a way to put $m$ weights on the scales by all rules. Otherwise, print in the first line "NO". If you can put $m$ weights on the scales, then print in the next line $m$ integers — the weights' weights in the order you put them on the scales.
If there are multiple solutions, you can print any of them.
If there are multiple solutions, you can print any of them.
输入输出样例
输入 #1
0000000101 3
输出 #1
YES 8 10 8
输入 #2
1000000000 2
输出 #2
NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted