Codeforces Round #486 (Div. 3) A. Diverse Team

题目连接:

http://codeforces.com/contest/988/problem/A

Description

There are n students in a school class, the rating of the i-th student on Codehorses is ai. You have to form a team consisting of

k students (1≤k≤n) such that the ratings of all team members are distinct.

If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print k distinct numbers which should be the indices of students in the team you form. If there are multiple answers, print any of them.

Input

The first line contains two integers n and k (1≤k≤n≤100) — the number of students and the size of the team you have to form.

The second line contains n integers a1,a2,…,an (1≤ai≤100), where

ai is the rating of i-th student.

Output

If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print k distinct integers from 1 to n which should be the indices of students in the team you form. All the ratings of the students in the team should be distinct. You may print the indices in any order. If there are multiple answers, print any of them.

Assume that the students are numbered from 1 to n.

Sample Input

5 3

15 13 15 15 12

Sample Output

YES

1 2 5

Hint

Note

All possible answers for the first example:

{1 2 5}

{2 3 5}

{2 4 5}

Note that the order does not matter.

题意

给你一个集合,问你有没有k元子集

题解:

用一个 set 来判重。

代码

#include <bits/stdc++.h>

using namespace std;

int n, k;
int cnt, x;
set<int> s;
queue<int> q; int main() {
cin >> n >> k;
while (!q.empty()) q.pop();
for (int i = 0; i < n && cnt < k; i++) {
cin >> x;
if (!s.count(x)) {
cnt++;
s.insert(x);
q.push(i + 1);
}
}
if (cnt >= k) {
cout << "YES" << endl;
while (!q.empty()) {
cout << q.front() << " ";
q.pop();
}
} else
puts("NO");
}

Codeforces Round #486 (Div. 3) A. Diverse Team的更多相关文章

  1. Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

    题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...

  2. Codeforces Round #486 (Div. 3) F. Rain and Umbrellas

    Codeforces Round #486 (Div. 3) F. Rain and Umbrellas 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  3. Codeforces Round #486 (Div. 3) E. Divisibility by 25

    Codeforces Round #486 (Div. 3) E. Divisibility by 25 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  4. Codeforces Round #486 (Div. 3) D. Points and Powers of Two

    Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...

  5. Codeforces Round #275 (Div. 1)A. Diverse Permutation 构造

    Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 ht ...

  6. 构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation

    题目传送门 /* 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放.因为是绝对差值,从n开始一下一上, 这样保证不会超出边界并且以防其余的数相邻绝对值差>k */ /*** ...

  7. Codeforces Round #275(Div. 2)-C. Diverse Permutation

    http://codeforces.com/contest/483/problem/C C. Diverse Permutation time limit per test 1 second memo ...

  8. Codeforces Round #379 (Div. 2) Analyses By Team:Red & Black

    A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lu ...

  9. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins

    http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的&qu ...

随机推荐

  1. centos7 安装gitlab任意版本

    主要还是根据官网:https://www.gitlab.cc/installation/#centos-7 1.安装依赖: sudo yum install curl policycoreutils ...

  2. js中的数值转换

    js中有3个函数可以把非数值转换为数值:Number().parseInt().parseFloat().其中Number()可以用于任何数据类型.parseInt()及parseFloat()用于将 ...

  3. java GC是在什么时候,对什么东西,做了什么事情

    面试题:“你能不能谈谈,java GC是在什么时候,对什么东西,做了什么事情?” 面试题目:地球人都知道,Java有个东西叫垃圾收集器,它让创建的对象不需要像c/cpp那样delete.free掉,你 ...

  4. mysql 表映射为java bean 手动生成。

    在日常工作中,一般是先建表.后建类.当然也有先UML构建类与类的层级关系,直接生成表.(建模)这里只针对先有表后有类的情况.不采用代码生成器的情况. 例如: 原表结构: ),)) BEGIN ); ) ...

  5. airbnb 开源reAir 工具 用法及源码解析(一)

    reAir 有批量复制与增量复制功能 今天我们先来看看批量复制功能 批量复制使用方式: cd reair ./gradlew shadowjar -p main -x test # 如果是本地tabl ...

  6. Python导出MySQL数据库中表的建表语句到文件

    为了做数据对象的版本控制,需要将MySQL数据库中的表结构导出成文件进行版本化管理,试写了一下,可以完整导出数据库中的表结构信息 # -*- coding: utf-8 -*- import os i ...

  7. js程序的调试方法

  8. pyspider示例代码:解析JSON数据

    pyspider示例代码官方网站是http://demo.pyspider.org/.上面的示例代码太多,无从下手.因此本人找出一下比较经典的示例进行简单讲解,希望对新手有一些帮助. 示例说明: py ...

  9. OpenStack安装-MySQL,Rabbitmq,memcache.

    基于前一篇的基本环境,现在我们开始安装MySQL. 在node1上面安装MySQL: [root@linux-node1 ~]# yum install mariadb mariadb-server ...

  10. jdango 使用oss存储

    安装django-aliyun-oss2-storage-0.1.5.tar.gz settings文件添加 MEDIA_ROOT = os.path.join(BASE_DIR,'upload/') ...