forked from anubhab91/CodeForces-5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiverseTeam.py
More file actions
40 lines (28 loc) · 1.2 KB
/
DiverseTeam.py
File metadata and controls
40 lines (28 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
__author__ = 'Devesh Bajpai'
'''
https://codeforces.com/problemset/problem/988/A
Solution: Using a brute-force approach, where a visited boolean array checks the presence of a number being seen or not.
This insures distinctness constraint. A result list maintains the final indices but indexed at 1.
As soon as the result list since reaches k, we return the decision YES and result list. If the loop that traverses on the
numbers exhausts and the result list hasn't reached k, the decision NO and null is returned.
'''
def solve(n, k, nums):
visited = [False for _ in range(101)]
result = []
currResultSize = 0
for i in xrange(0, n):
num = nums[i]
if not visited[num]:
visited[num] = True
result.append(i+1) #since the index referred in this problem starts at 1 instead of 0
currResultSize += 1
if currResultSize == k:
return "YES", result
return "NO", None
if __name__ == "__main__":
n, k = map(int,raw_input().split(" "))
nums = map(int,raw_input().split(" "))
decision, results = solve(n, k, nums)
print decision
if decision == "YES":
print ' '.join([str(result) for result in results])