CF339C.Xenia and Weights

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

泽妮娅有一组砝码和一架天平。每个砝码的重量均为 11 至 1010 千克之间的整数。泽妮娅打算用天平和砝码进行一个小游戏:她将砝码逐个放置到天平的两个托盘上,规则如下:第一个砝码放在左托盘,第二个砝码放在右托盘,第三个砝码放在左托盘,第四个砝码放在右托盘,依此类推。泽妮娅总共要放置 mm 个砝码。

仅仅把砝码放到天平上并不有趣,因此泽妮娅设定了一些规则:

  1. 她不会在天平上连续放置两个重量相同的砝码。即对任意 ii(其中 1≤i<m1 \le i < m),第 ii 个放置的砝码的重量必须与第 i+1i+1 个砝码的重量不同。

  2. 每次泽妮娅将一个砝码放到某个托盘上时,她都希望该托盘的总重量严格大于另一个托盘的总重量。也就是说,对应托盘上所有砝码的重量之和必须严格大于另一托盘上所有砝码的重量之和。

你将获得泽妮娅可用的所有砝码种类(重量值)。你可以假定每种指定重量的砝码数量是无限的。你的任务是帮助泽妮娅将 mm 个砝码按上述规则放置到天平上,或者判断这是不可能完成的。

输入格式

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

第一行包含一个恰好由十个 0 和 1 组成的字符串:该行中第 ii 个(i≥1i \geq 1)字符为 "1",当且仅当 Xenia 拥有重量为 ii 千克的砝码;否则该字符为 "0"。
第二行包含一个整数 mm(1≤m≤10001 \leq m \leq 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.

第一行输出 "YES",表示存在一种方式,按照所有规则将 m 个砝码放置到天平上;否则,第一行输出 "NO"。
如果可以放置 m 个砝码,则在下一行输出 m 个整数——即按你放置顺序排列的各砝码的重量。

若存在多种解法,输出任意一种即可。

输入输出样例

  • 输入#1

    0000000101
    3

    输出#1

    YES
    8 10 8
  • 输入#2

    1000000000
    2

    输出#2

    NO

输入解题思路,AI测评打分。不知道怎么写?

首页