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. WordPress版微信小程序2.1.5版发布

    WordPress版微信小程序功能已经基本完善,利用这套程序,搭配WordPress提供的rest api,WordPress网站的站长可以快速搭建属于自己的网站微信小程序 . WordPress版微 ...

  2. mysql数据库优化(三)--分区

    mysql的分区,分表 分区:把一个数据表的文件和索引分散存储在不同的物理文件中. 特点:业务层透明,无需任何修改,即使从新分表,也是在mysql层进行更改(业务层代码不动) 分表:把原来的表根据条件 ...

  3. 204. jetcache:在Spring Boot中怎么玩?

      [视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源 ...

  4. mysql实现IP与整形互转

  5. 一个判断I2C总线通信异常原因的方法

    此问题由某客户提出,应用处理器 AP与 MCU进行 I2C通信,通信会经常发生异常,需要定位原因. 首先需要定位的是因为哪个器件发的波形不正确导致通信异常,所以我们在 I2C 线路上增加了以下处理,增 ...

  6. Spring再接触 IOC DI

    直接上例子 引入spring以及Junite所需要的jar包 User.java package com.bjsxt.model; public class User { private String ...

  7. css选择器querySelectorAll

    * querySelectorAll(css的选择器)* 通过css的选择器获取到的一组元素* 获取的也是类数组** 主语* document 从整个页面去获取一组元素* 父级 从父级下去获取一组元素 ...

  8. CSS表单2 组件排版

    <!DOCTYPE html> <html>     <head>         <title>单选按钮对齐</title>        ...

  9. 计算机系统的通信PPT版本

    通信方式 并行传送:一次8位,需要保持各路信号同时到达,距离和速度受限制,成本较高 串行传送:一次1位,距离较远.速率更高,成本较低. {在单片机的通信中,使用的是串行传送,但是数据寄存器里面的是8位 ...

  10. 关于echarts图表在tab页中width:100%失效的问题

    https://www.cnblogs.com/tongrenlu/p/9268250.html