CF241D.Numbers

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have a sequence of n distinct integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ n). You want to remove some integers in such a way that the resulting sequence of integers satisfies the following three conditions:

  1. the resulting sequence is not empty;
  2. the exclusive or (xor operation) of all the integers in the resulting sequence equals 0;
  3. if you write all the integers of the resulting sequence (from beginning to the end) in a row in the decimal numeral system and without any spaces, the written number is divisible by p.

You are given the sequence of n integers a and a prime number p, find a way to satisfy the described conditions.

你有一个由 $ n $ 个互不相同的整数 $ a_1,,a_2,,\dots,,a_n $(其中 $ 1 \leq a_i \leq n $)组成的序列。你需要从中删除若干整数,使得剩余的整数序列满足以下三个条件:

  1. 剩余序列非空;
  2. 剩余序列中所有整数的异或(即 xor 运算)结果等于 $ 0 $;
  3. 若将剩余序列中的所有整数(从左到右)以十进制形式依次写出(中间不加空格),所得到的整数能被 $ p $ 整除。

给定整数序列 $ a $ 和一个质数 $ p $,请找出一种满足上述条件的删除方案。

输入格式

The first line of the input contains two integers n and p (1 ≤ n, p ≤ 50000). Next line contains n space-separated distinct integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ n).

It is guaranteed that p is a prime number.

输入的第一行包含两个整数 nn 和 pp(1 ≤ n, p ≤ 500001 \le n,\,p \le 50000)。下一行包含 nn 个用空格分隔的互不相同的整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n(1 ≤ ai ≤ n1 \le a_i \le n)。

保证 pp 是一个质数。

输出格式

If there is no solution for the given input, print "No" (without quotes) in the only line of the output.

Otherwise print "Yes" in the first line of output. The second line should contain an integer k (k > 0) specifying the number of remaining elements and the third line should contain k distinct integers _x_1, _x_2, ..., x__k (1 ≤ x__i ≤ n). These integers mean that you should remove all integers from the sequence except integers _a__x_1, _a__x_2, ..., a__x__k to satisfy the described conditions.

If there are multiple solutions, any of them will be accepted.

如果给定输入无解,则在输出的唯一一行中打印“No”(不带引号)。

否则,在输出的第一行打印“Yes”。第二行应包含一个整数 kk(k>0k > 0),表示剩余元素的个数;第三行应包含 kk 个互不相同的整数 x1, x2, …, xkx_1,\,x_2,\,\dots,\,x_k(其中 1≤xi≤n1 \le x_i \le n)。这些整数表示:应从序列中移除所有整数,仅保留 ax1, ax2, …, axka_{x_1},\,a_{x_2},\,\dots,\,a_{x_k},以满足题目所述条件。

若存在多个解,输出任意一个均可。

输入输出样例

  • 输入#1

    3 3
    1 2 3

    输出#1

    Yes
    3
    1 2 3
  • 输入#2

    3 5
    1 2 3

    输出#2

    No

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

首页