message stringlengths 2 20.1k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 1.95k 109k | cluster float64 17 17 | __index_level_0__ int64 3.91k 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000 | instruction | 0 | 80,514 | 17 | 161,028 |
Tags: implementation, math
Correct Solution:
```
import math
import itertools
import collections
def getdict(n):
d = {}
if type(n) is list:
for i in n:
if i in d:
d[i] += 1
else:
d[i] = 1
else:
for i in range(n):
t = ii()
if t in d:
d[t] += 1
else:
d[t] = 1
return d
def cdiv(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a*b) // math.gcd(a, b)
def wr(arr): return ' '.join(map(str, arr))
def prime(n):
if n == 2:
return True
if n % 2 == 0 or n <= 1:
return False
sqr = int(math.sqrt(n)) + 1
for d in range(3, sqr, 2):
if n % d == 0:
return False
return True
def revn(n):
m = 0
while n > 0:
m = m * 10 + n % 10
n = n // 10
return m
n, k = mi()
if k + 1 > n // 2:
print(0, 0, n)
else:
d = (n // 2) // (k + 1)
print(d, d * k, n - (k + 1) * d)
``` | output | 1 | 80,514 | 17 | 161,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000 | instruction | 0 | 80,515 | 17 | 161,030 |
Tags: implementation, math
Correct Solution:
```
n,k = map(int,input().strip().split(' '))
w = int(n/2);
x = int(w/(k+1))
print(str(x)+' '+str(int(x*k))+' '+str(int(n - x - x*k)))
``` | output | 1 | 80,515 | 17 | 161,031 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000 | instruction | 0 | 80,516 | 17 | 161,032 |
Tags: implementation, math
Correct Solution:
```
n,k=list(map(int,input().split()))
d=n//2//(k+1)
print(d,d*k,n-d*(k+1))
``` | output | 1 | 80,516 | 17 | 161,033 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000 | instruction | 0 | 80,517 | 17 | 161,034 |
Tags: implementation, math
Correct Solution:
```
import math
z , k = map(int , input().split())
tmp = z
z //= 2
x = int(z / (k + 1))
y = int(x * k)
print(x , y , tmp - x - y)
``` | output | 1 | 80,517 | 17 | 161,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
from sys import stdin, stdout
n, k = map(int, stdin.readline().split())
l, r = 0, n // 2
while (r - l > 1):
m = (r + l) // 2
if m * k + m > n / 2:
r = m
else:
l = m
stdout.write(str(l) + ' ' + str(l * k) + ' ' + str(n - l * (k + 1)))
``` | instruction | 0 | 80,518 | 17 | 161,036 |
Yes | output | 1 | 80,518 | 17 | 161,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
if __name__ == '__main__':
str = input()
(n, k) = str.split(' ')
n = int(n)
k = int(k)
a = n // 2 // (k+1)
b = a * k
c = n - a - b
print(a, b, c)
``` | instruction | 0 | 80,519 | 17 | 161,038 |
Yes | output | 1 | 80,519 | 17 | 161,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
n, k = [int(i) for i in input().split()]
max_wins = n // 2;
diplo = (max_wins // (k + 1))
certi = diplo * k
print(diplo, certi, n - diplo - certi)
``` | instruction | 0 | 80,520 | 17 | 161,040 |
Yes | output | 1 | 80,520 | 17 | 161,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
n,k = map(int,input().split())
d = (n//2)//(k+1)
print(d,k*d,n-d-k*d)
``` | instruction | 0 | 80,521 | 17 | 161,042 |
Yes | output | 1 | 80,521 | 17 | 161,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
def read_tokens():
return input().strip().split(' ')
def read_ints():
return [int(s) for s in read_tokens()]
n, k = read_ints()
def solve(n, k):
prizer = n // 2
if prizer // k == 0:
print(0, 0, n)
return
bad = 1
good = max(n,k)
while good - bad > 1:
diploma = (good + bad) // 2
if diploma * k + diploma >= prizer:
good = diploma
else:
bad = diploma
if good + good*k == prizer:
print(good, good*k, n - good - good*k)
print(bad, bad * k, n - bad - bad*k)
solve(n, k)
``` | instruction | 0 | 80,522 | 17 | 161,044 |
No | output | 1 | 80,522 | 17 | 161,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
def diplomas(n, k):
return ((n // 2) // (k + 1)), ((n // 2) // (k + 1)) * k, n - ((n // 2) // (k + 1)) - ((n // 2) // (k + 1)) * k
N, K = [int(i) for i in input().split()]
print(diplomas(N, K))
``` | instruction | 0 | 80,523 | 17 | 161,046 |
No | output | 1 | 80,523 | 17 | 161,047 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
n,k=map(int,input().split())
if k+1>n//2:
p=0
q=0
r=n
print(p,q,r)
exit()
x=(n//2)//(k+1)
y=k*x
print(x,y,n//2)
``` | instruction | 0 | 80,524 | 17 | 161,048 |
No | output | 1 | 80,524 | 17 | 161,049 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
Submitted Solution:
```
n, k = [int(number) for number in input().split()]
a = n//2//(k+1)
b = n//2-a
c=n-a-b
if k >= n:
print(0, 0, n)
else:
print(a, b, c)
``` | instruction | 0 | 80,525 | 17 | 161,050 |
No | output | 1 | 80,525 | 17 | 161,051 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,586 | 17 | 161,172 |
Tags: brute force, implementation
Correct Solution:
```
a,b=map(int,input().split())
p=set()
q=set()
list1=list(map(int,input().split()))
for i in range(a):
if len(q)==b:
continue
siz=len(p)
p.add(list1[i])
if siz==len(p):
continue
q.add(i+1)
if len(p)<b:
print("NO")
else:
print("YES")
list2=list(q)
for i in range(len(q)):
print(str(list2[i])+" ",end="")
``` | output | 1 | 80,586 | 17 | 161,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,587 | 17 | 161,174 |
Tags: brute force, implementation
Correct Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(set(a))
if len(b)>=k:
print('YES')
print(a.index(b[0])+1,end='')
for i in range(1,k):print(' '+str(a.index(b[i])+1),end='')
else:print('NO')
``` | output | 1 | 80,587 | 17 | 161,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,588 | 17 | 161,176 |
Tags: brute force, implementation
Correct Solution:
```
R = lambda: map(int, input().split())
n,k = R()
L = list(R())
if len(set(L)) < k:
print("NO")
else:
print("YES")
a = list(set(L))
res = []
for i in a:
if k > 0:
res.append(L.index(i)+1)
k -= 1
print(*sorted(res))
``` | output | 1 | 80,588 | 17 | 161,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,589 | 17 | 161,178 |
Tags: brute force, implementation
Correct Solution:
```
# 988A - Diverse Team
# https://codeforces.com/contest/988/problem/A
line1 = list(map(int, input().strip().split()))
line2 = list(map(int, input().strip().split()))
n = line1[0]
k = line1[1]
distinct = []
distinct_position = []
for i,rating in enumerate(line2):
if distinct.count(rating) == 0:
distinct.append(rating)
distinct_position.append(i+1)
if len(distinct) == k:
break
if len(distinct) < k:
print('NO')
else:
print('YES')
for position in distinct_position:
print(position, end=' ')
``` | output | 1 | 80,589 | 17 | 161,179 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,590 | 17 | 161,180 |
Tags: brute force, implementation
Correct Solution:
```
from collections import *
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=Counter(a)
if(len(f)<k):
print("NO")
else:
print("YES")
c=0
for i in f.keys():
c+=1
print(a.index(i)+1,end=" ")
if(c==k):
break
``` | output | 1 | 80,590 | 17 | 161,181 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,591 | 17 | 161,182 |
Tags: brute force, implementation
Correct Solution:
```
n,k=map(int,input().split())
S=[int(x) for x in input().split()]
A=set(S)
if len(A) >= k:
print("YES")
Ans=[]
for a in A:
Ans.append(S.index(a)+1)
Ans=Ans[:k]
print(*Ans)
else:
print("NO")
``` | output | 1 | 80,591 | 17 | 161,183 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,592 | 17 | 161,184 |
Tags: brute force, implementation
Correct Solution:
```
m,n = input().split()
m,n = int(m),int(n)
lst = input().split()
n_lst = []
n_lst.append(lst[0])
n_lst1 = [1]
for i in range(1,len(lst)):
if lst[i] not in n_lst:
n_lst.append(lst[i])
n_lst1.append(i+1)
if len(n_lst1)>=n:
print('YES')
for i in range(n):
print(n_lst1[i],end=' ')
else:
print('NO')
``` | output | 1 | 80,592 | 17 | 161,185 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter. | instruction | 0 | 80,593 | 17 | 161,186 |
Tags: brute force, implementation
Correct Solution:
```
def check(i,a,c):
for x in range(i+1,len(c)):
if c[x]==a:
c[x]=-1
if __name__=="__main__":
n,k=input().strip().split(' ')
n,k=[int(n),int(k)]
a=list(map(int,input().strip().split(' ')))
count=0
for x in range(0,len(a)):
if a[x]!=-1:
check(x,a[x],a)
for x in range(0,len(a)):
if a[x]!=-1:
count+=1
#print(a)
#print(count)
if count>=k:
print('YES')
for x in range(0,len(a)):
if k==0:
break
if a[x]!=-1:
print(x+1,end=' ')
k-=1
print()
else:
print('NO')
``` | output | 1 | 80,593 | 17 | 161,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
n, k = map(int, input().split(" "))
ls = list(map(int, input().split(" ")))
s = set(ls)
b = list(s)
res = []
if len(s) < k:
print("NO")
else:
print("YES")
for t in range(k):
res.append(ls.index(b[t]) +1)
print(*res)
``` | instruction | 0 | 80,594 | 17 | 161,188 |
Yes | output | 1 | 80,594 | 17 | 161,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
n,k=map(int,input().split())
x=[*map(int,input().split())]
dad=dict()
a=[]
c=0
for n,i in enumerate(x):
if dad.get(i,0)==0:
a.append(n+1)
c+=1
if c==k: break
dad[i]=1
if c<k: print('NO')
else:
print('YES')
for i in a: print(i,end=' ')
``` | instruction | 0 | 80,595 | 17 | 161,190 |
Yes | output | 1 | 80,595 | 17 | 161,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
l = input().split()
n = int(l[0])
k = int(l[1])
reap = 0
v = input().split()
v2 = []
for i in range(n):
if int(v[i]) not in v2:
v2.append(int(v[i]))
else:
reap += 1
if n - reap < k:
print("NO")
else:
v2 = []
v3 = []
for i in range(n):
if v[i] not in v2:
v2.append(v[i])
v3.append(str(i+1))
if len(v3)==k:
break
print("YES")
print(' '.join(v3))
``` | instruction | 0 | 80,596 | 17 | 161,192 |
Yes | output | 1 | 80,596 | 17 | 161,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=set(a)
l=[]
if len(b)>=k:
print("YES")
for i in b:
l.append(a.index(i)+1)
r=sorted(l)
for i in range(k):
print(r[i],end=' ')
else:
print("NO")
``` | instruction | 0 | 80,597 | 17 | 161,194 |
Yes | output | 1 | 80,597 | 17 | 161,195 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
"""
██╗ ██████╗ ██╗ ██████╗ ██████╗ ██╗ █████╗
██║██╔═══██╗██║ ╚════██╗██╔═████╗███║██╔══██╗
██║██║ ██║██║ █████╔╝██║██╔██║╚██║╚██████║
██║██║ ██║██║ ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
██║╚██████╔╝██║ ███████╗╚██████╔╝ ██║ █████╔╝
╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚════╝
"""
n, k = map(int, input().split())
m = list(map(int, input().split()))
a = len(set(m))
if a < k:
print("NO")
exit()
print("YES")
score = []
ind = []
for i in range(n):
if m[i] not in score:
ind += [i + 1]
score += [m[i]]
print(* ind, sep = " ")
``` | instruction | 0 | 80,598 | 17 | 161,196 |
No | output | 1 | 80,598 | 17 | 161,197 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
#998/A
_=list(map(int,input().split()))
__=list(map(int,input().split()))
___=list(set(__))
print("YES" if len(___)>=_[1] else "NO")
for ____ in range(len(___)):
print(__.index(___[____])+1,end=" ")
``` | instruction | 0 | 80,599 | 17 | 161,198 |
No | output | 1 | 80,599 | 17 | 161,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
a,b = map(int,input().split())
x = list(map(int,input().split()))
r = set(x)
if len(r)>=b:
print("YES")
else:
print("NO")
``` | instruction | 0 | 80,600 | 17 | 161,200 |
No | output | 1 | 80,600 | 17 | 161,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. 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 a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i 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.
Examples
Input
5 3
15 13 15 15 12
Output
YES
1 2 5
Input
5 4
15 13 15 15 12
Output
NO
Input
4 4
20 10 40 30
Output
YES
1 2 3 4
Note
All possible answers for the first example:
* {1 2 5}
* {2 3 5}
* {2 4 5}
Note that the order does not matter.
Submitted Solution:
```
yoar=list(map(int,input().split()))
n=yoar[0]
k=yoar[1]
arr=list(map(int,input().split()))
ans=[]
yoar=[]
for i in range(n):
if arr[i] not in yoar:
yoar.append(arr[i])
ans.append(i)
if len(ans)<k:
print("NO")
else:
print("YES")
for i in ans:
print(i+1,end=" ")
print()
# setar=ser(arr)
# if len(setar<k):
# print("NO")
# else:
# ans=[]
# for i in range(n):
``` | instruction | 0 | 80,601 | 17 | 161,202 |
No | output | 1 | 80,601 | 17 | 161,203 |
Provide a correct Python 3 solution for this coding contest problem.
Description
THE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this month.
This game is a game in which members of the unit (formation) to be produced are selected from the bidders, and through lessons and communication with the members, they (they) are raised to the top of the bidders, the top biddles.
Each bidle has three parameters, vocal, dance, and looks, and the unit's ability score is the sum of all the parameters of the biddles that belong to the unit. The highest of the three stats of a unit is the rank of the unit.
There is no limit to the number of people in a unit, and you can work as a unit with one, three, or 100 members. Of course, you can hire more than one of the same bidle, but hiring a bidle is expensive and must be taken into account.
As a producer, you decided to write and calculate a program to make the best unit.
Input
The input consists of multiple test cases.
The first line of each test case is given the number N of bid dollars and the available cost M. (1 <= N, M <= 300) The next 2 * N lines contain information about each bidle.
The name of the bidle is on the first line of the bidle information. Biddle names consist of alphabets and spaces, with 30 characters or less. Also, there is no bidle with the same name.
The second line is given the integers C, V, D, L. C is the cost of hiring one Biddle, V is the vocal, D is the dance, and L is the stat of the looks. (1 <= C, V, D, L <= 300)
Input ends with EOF.
Output
Answer the maximum rank of units that can be made within the given cost.
If you cannot make a unit, output 0.
Example
Input
3 10
Dobkeradops
7 5 23 10
PataPata
1 1 2 1
dop
5 3 11 14
2 300
Bydo System Alpha
7 11 4 7
Green Inferno
300 300 300 300
Output
29
462 | instruction | 0 | 80,769 | 17 | 161,538 |
"Correct Solution:
```
while True:
try:
n, m = map(int, input().split())
except EOFError:
break
costs = []
vocals = []
dances = []
looks = []
for _ in range(n):
input()
c, v, d, l = map(int, input().split())
costs.append(c)
vocals.append(v)
dances.append(d)
looks.append(l)
def max_param(params):
dp = [0] * (m + 1)
for i in range(n):
c = costs[i]
p = params[i]
for j in range(m - c + 1):
dp[j + c] = max(dp[j + c], dp[j] + p)
return dp[-1]
print(max(max_param(vocals), max_param(dances), max_param(looks)))
``` | output | 1 | 80,769 | 17 | 161,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,376 | 17 | 162,752 |
Tags: binary search, implementation
Correct Solution:
```
import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65
def getInt():
return int(sys.stdin.readline().rstrip())
def getInts():
return map(int, sys.stdin.readline().rstrip().split(" "))
def getString():
return sys.stdin.readline().rstrip()
def printOutput(th, d, ordering):
sys.stdout.write(str(th) + "\n")
for target in ordering:
if target in d:
sys.stdout.write(str(d[target]) + " ")
else:
sys.stdout.write(str(-1) + " ")
sys.stdout.write("\n")
def binSearch(t, x):
l = 0
r = len(t) - 1
while l <= r:
m = (l + r) // 2
if t[m][0] >= x:
r = m - 1
else:
l = m + 1
return r
def distFrom(point, xPos):
x1, y1 = xPos, 0
x2, y2 = point
return abs(x2 - x1) ** 2 + abs(y2 - y1) ** 2
def solve(t, s):
d = dict()
targetsHit = 0
for x, y, shotNum in s:
m = binSearch(
t, x
) # find target to left if exists, and target to right if exists
l = None
r = None
if 0 <= m <= len(t) - 1:
l = m
if 0 <= m + 1 <= len(t) - 1:
r = m + 1
if l != None:
pos, rad = t[l]
df = distFrom((x, y), pos)
if df <= rad ** 2:
if pos not in d:
d[pos] = shotNum
targetsHit += 1
if r != None:
pos, rad = t[r]
df = distFrom((x, y), pos)
if df <= rad ** 2:
if pos not in d:
d[pos] = shotNum
targetsHit += 1
return targetsHit, d
def readinput():
n = getInt()
originalOrdering = []
targets = []
for _ in range(n):
pos, rad = getInts()
originalOrdering.append(pos)
targets.append((pos, rad))
targets.sort()
s = getInt()
shots = []
for i in range(s):
x, y = getInts()
shots.append((x, y, i + 1)) # x coord, y coord, shot number
targetsHit, d = solve(targets, shots)
printOutput(targetsHit, d, originalOrdering)
readinput()
``` | output | 1 | 81,376 | 17 | 162,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,377 | 17 | 162,754 |
Tags: binary search, implementation
Correct Solution:
```
def main():
from array import array
from bisect import bisect
from sys import stdin
input = stdin.readline
O = -1
n = int(input())
xr = []
for i in range(n):
xi, ri = map(int, input().split())
xr.append((xi, ri ** 2, i))
xr.sort()
cur = 1
res1 = 0
res2 = array('i', (O,)) * n
for _2 in range(int(input())):
x2, y = map(int, input().split())
bs = bisect(xr, (x2,))
for i in bs, bs - 1:
if i < n:
xi, ri2, ii = xr[i]
if res2[ii] == O and (xi - x2) ** 2 + y ** 2 <= ri2:
res1 += 1
res2[ii] = cur
cur += 1
print(res1)
print(*res2)
main()
``` | output | 1 | 81,377 | 17 | 162,755 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,378 | 17 | 162,756 |
Tags: binary search, implementation
Correct Solution:
```
from sys import stdin
def read(line):
return [int(c) for c in line.split()]
test = stdin.readlines()
n = int(test[0])
targets = []
for i in range(1, n+1):
targets.append(read(test[i]))
m = int(test[n + 1])
shots = []
for i in range(n + 2, n + 2 + m):
shots.append(read(test[i]))
grid = [-1] * 80000
for i, t in enumerate(targets):
x, r = t
for k in range(x - r, x + r + 1):
if grid[k + 40000] == -1:
grid[k + 40000] = i
else:
grid[k + 40000] = [grid[k + 40000], i]
ans = [-1] * n
for k, s in enumerate(shots, 1):
x, y = s
t = grid[x + 40000]
if t != -1 and type(t) == int:
xx, r = targets[t]
if (xx - x) * (xx - x) + y * y <= r * r and ans[t] == -1:
ans[t] = k
elif type(t) == list:
xx, r = targets[t[0]]
if (xx - x) * (xx - x) + y * y <= r * r and ans[t[0]] == -1:
ans[t[0]] = k
xx, r = targets[t[1]]
if (xx - x) * (xx - x) + y * y <= r * r and ans[t[1]] == -1:
ans[t[1]] = k
print(sum(1 for e in ans if e != -1))
print(*ans)
``` | output | 1 | 81,378 | 17 | 162,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,379 | 17 | 162,758 |
Tags: binary search, implementation
Correct Solution:
```
input=__import__('sys').stdin.readline
import math
n = int(input())
lis=[]
for i in range(n):
a,b = map(int,input().split())
lis.append([a,b,i])
lis.sort()
m = int(input())
ans=[-1]*(n)
c=0
for i in range(m):
a,b = map(int,input().split())
l=0
r=n-1
while l<=r:
mid = l + (r-l)//2
if lis[mid][0]<=a:
l = mid+1
else:
r = mid-1
ral=1000000000000000
if l<=n-1:
ral = math.sqrt(((a-lis[l][0])**2 + b**2))
rar = math.sqrt(((a-lis[r][0])**2 + b**2))
if l<n and ral<=lis[l][1] and ans[lis[l][2]]==-1:
ans[lis[l][2]]=i+1
c+=1
if r<n and rar<=lis[r][1] and ans[lis[r][2]]==-1:
ans[lis[r][2]]=i+1
c+=1
print(c)
print(*ans)
``` | output | 1 | 81,379 | 17 | 162,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,380 | 17 | 162,760 |
Tags: binary search, implementation
Correct Solution:
```
from sys import stdin, stdout
n = int(stdin.readline())
challengers = []
for i in range(n):
a, b = map(int, stdin.readline().split())
challengers.append((a, b, i))
challengers.sort()
ans = [float('inf') for i in range(n)]
m = int(stdin.readline())
questions = []
for i in range(m):
x, y = map(int, stdin.readline().split())
l, r = -1, n
while (r - l > 1):
m = (r + l) // 2
if challengers[m][0] <= x:
l = m
else:
r = m
if l >= 0 and (challengers[l][0] - x) ** 2 + y ** 2 <= challengers[l][1] ** 2:
ans[challengers[l][2]] = min(ans[challengers[l][2]], i + 1)
if r < n and (challengers[r][0] - x) ** 2 + y ** 2 <= challengers[r][1] ** 2:
ans[challengers[r][2]] = min(ans[challengers[r][2]], i + 1)
stdout.write(str(n - ans.count(float('inf'))) + '\n')
for i in range(n):
if ans[i] == float('inf'):
stdout.write('-1' + ' \n'[i == n - 1])
else:
stdout.write(str(ans[i]) + ' \n'[i == n - 1])
``` | output | 1 | 81,380 | 17 | 162,761 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,381 | 17 | 162,762 |
Tags: binary search, implementation
Correct Solution:
```
'''input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
'''
from sys import stdin
from bisect import bisect_left
from collections import OrderedDict
def check(c, r, x, y):
if x**2 + y**2 - 2*x*c + c**2 <= r**2:
return True
else:
return False
# main starts
n = int(stdin.readline().strip())
rdict = OrderedDict()
center = []
for _ in range(n):
c, r = list(map(int, stdin.readline().split()))
rdict[c] = r
center.append(c)
center.sort()
ans = dict()
m = int(stdin.readline().strip())
for i in range(m):
x, y = list(map(int, stdin.readline().split()))
index = bisect_left(center, x)
if index > 0 and index < len(center):
if check(center[index], rdict[center[index]], x, y):
if center[index] not in ans:
ans[center[index]] = i + 1
if check(center[index - 1], rdict[center[index - 1]], x, y):
if center[index - 1] not in ans:
ans[center[index - 1]] = i + 1
elif index == 0:
if check(center[index], rdict[center[index]], x, y):
if center[index] not in ans:
ans[center[index]] = i + 1
elif index == len(center):
if check(center[index - 1], rdict[center[index - 1]], x, y):
if center[index - 1] not in ans:
ans[center[index - 1]] = i + 1
print(len(ans))
for i in rdict:
if i in ans:
print(ans[i], end = ' ')
else:
print(-1, end = ' ')
``` | output | 1 | 81,381 | 17 | 162,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,382 | 17 | 162,764 |
Tags: binary search, implementation
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
#vsInput()
def inside(x,y,c):
#print(x,y,c)
R=radius[c]**2
X=(x-c)**2
Y=y**2
return X+Y<=R
centers=[]
radius={}
ID={}
n=Int()
for _ in range(n):
c,r=value()
centers.append(c)
ID[_]=c
radius[c]=r
centers.sort()
m=Int()
shots=[]
status=defaultdict(lambda:-1)
for _ in range(m):
shots.append(value())
for i in range(1,m+1):
x,y=shots[i-1]
ind=bisect_left(centers,x)
#print(x,y,ind)
if(ind<n and inside(x,y,centers[ind]) and status[centers[ind]]==-1):
status[centers[ind]]=i
ind-=1
if(ind>=0 and inside(x,y,centers[ind]) and status[centers[ind]]==-1):
status[centers[ind]]=i
print(len(status))
# print(ID,status)
# print(centers)
for i in range(n):
print(status[ID[i]],end=" ")
``` | output | 1 | 81,382 | 17 | 162,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4 | instruction | 0 | 81,383 | 17 | 162,766 |
Tags: binary search, implementation
Correct Solution:
```
import sys
from array import array # noqa: F401
from math import hypot
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n = int(input())
circle = sorted((x - r, x, r, i) for i, (x, r) in enumerate((map(int, input().split()) for _ in range(n)))) + [(10**9, 10**9, 10**9, 10**9)]
m = int(input())
shoot = sorted(tuple(map(int, input().split())) + (i,) for i in range(1, m + 1)) + [(10**9, 10**9, 10**9)]
inf, eps = 10**9, 1e-9
ans = [inf] * n
si = 0
for j, (sx, x, r, i) in zip(range(n), circle):
while shoot[si][0] < sx:
si += 1
while sx <= shoot[si][0] <= x + r:
if hypot(x - shoot[si][0], shoot[si][1]) - eps < r and ans[i] > shoot[si][2]:
ans[i] = shoot[si][2]
if shoot[si][1] == 0 and circle[j + 1][0] == shoot[si][0] and ans[circle[j + 1][3]] > shoot[si][2]:
ans[circle[j + 1][3]] = shoot[si][2]
si += 1
cnt = n
for i in range(n):
if ans[i] == inf:
ans[i] = -1
cnt -= 1
sys.stdout.buffer.write((str(cnt) + '\n' + ' '.join(map(str, ans))).encode('utf-8'))
``` | output | 1 | 81,383 | 17 | 162,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4
Submitted Solution:
```
import bisect
O = -1
n = int(input())
xr = []
for i in range(n):
xi, ri = map(int, input().split())
xr.append((xi, ri ** 2, i))
xr.sort()
cur = 1
res1 = 0
res2 = [O] * n
for _2 in range(int(input())):
x2, y = map(int, input().split())
bs = bisect.bisect(xr, (x2,))
for i in bs, bs - 1:
if i < n and res2[i] == O and (xr[i][0] - x2) ** 2 + y ** 2 <= xr[i][1]:
res1 += 1
res2[xr[i][2]] = cur
cur += 1
print(res1)
print(*res2)
``` | instruction | 0 | 81,384 | 17 | 162,768 |
No | output | 1 | 81,384 | 17 | 162,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4
Submitted Solution:
```
import bisect
O = -1
n = int(input())
i = 1
xr = []
for _ in range(n):
xi, ri = map(int, input().split())
xr.append((xi, ri ** 2, i))
i += 1
xr.sort()
cur = 1
res1 = 0
res2 = [O] * n
for _2 in range(int(input())):
x2, y = map(int, input().split())
bs = bisect.bisect(xr, (x2,))
for i in bs, bs - 1:
if i < n and res2[i] == O and (xr[i][0] - x2) ** 2 + y ** 2 <= xr[i][1]:
res1 += 1
res2[i] = cur
cur += 1
print(res1)
print(*res2)
``` | instruction | 0 | 81,385 | 17 | 162,770 |
No | output | 1 | 81,385 | 17 | 162,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4
Submitted Solution:
```
import array, bisect, collections, copy, fractions, functools, heapq, itertools, math, random, re, string, sys, time, os
from decimal import Decimal
sys.setrecursionlimit(10000000)
inf = float('inf')
def li(): return [int(x) for x in sys.stdin.readline().split()]
def li_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def lf(): return [float(x) for x in sys.stdin.readline().split()]
def ls(): return sys.stdin.readline().split()
def int_inp(): return int(sys.stdin.readline())
def float_inp(): return float(sys.stdin.readline())
def inp(): return sys.stdin.readline().strip()
def pf(s): return print(s, flush=True)
def main():
if os.path.exists('input.txt'):
sys.stdin = open('input.txt', 'r')
# --------------------------------INPUT----------------------------------
n = int_inp()
circles = []
ans = collections.defaultdict(int)
for _ in range(n):
x, r = li()
circles.append(tuple((x, r * r)))
fff = circles.copy()
circles.sort()
j = 1
for _ in range(int_inp()):
x, y = li()
i = bisect.bisect_right(circles, (x, y))
i = max(i, 1)
i = min(n - 1, i)
k = fff.index(circles[i])
if (circles[i][0] - x) ** 2 + y * y <= circles[i][1]:
if k not in ans:
ans[k] = j
if (circles[i - 1][0] - x) ** 2 + y * y <= circles[i - 1][1]:
if k - 1 not in ans:
ans[k - 1] = j
j += 1
output = []
x = 0
for i in range(n):
if ans[i]:
x += 1
output.append(str(ans[i]))
else:
output.append('-1')
print(x)
print(' '.join(output))
# -------------------------------OUTPUT----------------------------------
if os.path.exists('output.txt'):
sys.stdout = open('output.txt', 'w')
# sys.stdout.write(f'{ans}')
if __name__ == '__main__':
main()
``` | instruction | 0 | 81,386 | 17 | 162,772 |
No | output | 1 | 81,386 | 17 | 162,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon.
As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about.
On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with n targets. Each target have shape of a circle, and the center of each circle is located on the Ox axis. At the last training session Valera made the total of m shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.
Input
The first line of the input file contains the integer n (1 ≤ n ≤ 104), which is the number of targets. The next n lines contain descriptions of the targets. Each target is a circle whose center is located on the Ox axis. Each circle is given by its coordinate of the center x ( - 2·104 ≤ x ≤ 2·104) and its radius r (1 ≤ r ≤ 1000). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other.
The next line contains integer m (1 ≤ m ≤ 2·105), which is the number of shots. Next m lines contain descriptions of the shots, which are points on the plane, given by their coordinates x and y ( - 2·104 ≤ x, y ≤ 2·104).
All the numbers in the input are integers.
Targets and shots are numbered starting from one in the order of the input.
Output
Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.
Examples
Input
3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0
Output
2
3 3 -1
Input
3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2
Output
3
1 2 4
Submitted Solution:
```
import bisect
O = -1
n = int(input())
x = []
r = []
for _ in range(n):
xi, ri = input().split()
x.append(int(xi))
r.append(int(ri) ** 2)
cur = 1
res1 = 0
res2 = [O] * n
for _2 in range(int(input())):
x2, y = map(int, input().split())
bs = bisect.bisect(x, x2)
for i in bs, bs - 1:
if i < n and res2[i] == O and (x[i] - x2) ** 2 + y ** 2 <= r[i]:
res1 += 1
res2[i] = cur
cur += 1
print(res1)
print(*res2)
``` | instruction | 0 | 81,387 | 17 | 162,774 |
No | output | 1 | 81,387 | 17 | 162,775 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,618 | 17 | 163,236 |
"Correct Solution:
```
WIN = "0"
LOSE = "1"
while True:
input_count = int(input())
if input_count == 0:
break
input_list = [input().split(" ") for _ in range(input_count)]
count_list = [(item[0], item.count(WIN), item.count(LOSE)) for item in input_list]
count_list.sort(key=lambda item: (-item[1], item[2]))
output = [item[0] for item in count_list]
print("\n".join(output))
``` | output | 1 | 81,618 | 17 | 163,237 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,619 | 17 | 163,238 |
"Correct Solution:
```
if __name__ == '__main__':
while True:
try:
n = int(input())
if n == 0:
break
A = []
for _ in range(n):
cmd = input().split()
A.append((cmd.count("0"),cmd.count("1"),cmd.count("2"),cmd[0]))
B = sorted(A,key=lambda x:(-x[0],x[1],x[2]))
for y in B:
print(y[3])
except EOFError:
break
``` | output | 1 | 81,619 | 17 | 163,239 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,620 | 17 | 163,240 |
"Correct Solution:
```
while True:
L = []
n = int(input())
if n == 0:
break
for i in range(n):
r = list(input().split())
t = r.pop(0)
w = l = 0
for a in r:
if int(a) == 0:
w += 1
elif int(a) == 1:
l += 1
L.append((t,w,l,i))
for i in sorted(L, key = lambda x:(-x[1],x[2],x[3])):
print(i[0])
``` | output | 1 | 81,620 | 17 | 163,241 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,621 | 17 | 163,242 |
"Correct Solution:
```
while True:
n = int(input())
if n == 0:
break
ls = []
for i in range(n):
v = input().split()
sum = 0
for j in range(1,n):
v[j] = int(v[j])
if v[j] == 0:
sum += 100
if v[j] == 1:
sum -= 1
ls.append([sum,-i,v[0]])
ls = sorted(ls)
ls.reverse()
for i in range(n):
print(ls[i][2])
``` | output | 1 | 81,621 | 17 | 163,243 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,622 | 17 | 163,244 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0196
"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline
def main(args):
while True:
n = int(input())
if n == 0:
break
pq = []
for seq in range(n):
temp = input().split()
team_name = temp[0]
temp = temp[1:]
win_count = temp.count('0')
lose_count = temp.count('1')
heappush(pq, (-win_count, lose_count, seq, team_name))
while pq:
_, _, _, team_name = heappop(pq)
print(team_name)
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 81,622 | 17 | 163,245 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,623 | 17 | 163,246 |
"Correct Solution:
```
# AOJ 0196 Baseball Championship
# Python3 2018.6.21 bal4u
while 1:
n = int(input())
if n == 0: break
team = []
for i in range(n):
r = list(input())
t = r.pop(0)
w = l = 0
for p in r:
if p.isdigit() == False: pass
elif int(p) == 0: w += 1 # 勝ち数
elif int(p) == 1: l += 1 # 負け数
team.append((t, i, w, l))
for i in sorted(team, key=lambda x:(-x[2],x[3],x[1])): print(*i[0])
``` | output | 1 | 81,623 | 17 | 163,247 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,624 | 17 | 163,248 |
"Correct Solution:
```
from collections import Counter
while True:
n=int(input())
if n==0:
break
scores=[]
for i in range(n):
s=input().split(" ")
team=s[0]
score=s[1:]
c=Counter(score)
c=dict(c)
result=[team,c.get('0',0),c.get('1',0),c.get('2',0)]
scores.append(result)
scores=sorted(scores,key=lambda w: w[1]*100+w[3],reverse=True)
for s in scores:
print(s[0])
``` | output | 1 | 81,624 | 17 | 163,249 |
Provide a correct Python 3 solution for this coding contest problem.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g | instruction | 0 | 81,625 | 17 | 163,250 |
"Correct Solution:
```
def solve():
from sys import stdin
f_i = stdin
ans = ""
while True:
n = int(f_i.readline())
if n == 0:
break
result = []
for i in range(n):
score = f_i.readline()
t = score[0]
win = score.count('0')
lose = score.count('1')
result.append((-win, lose, i, t))
result.sort()
ans += '\n'.join(map(lambda x: x[-1], result))
ans += '\n'
print(ans, end='')
solve()
``` | output | 1 | 81,625 | 17 | 163,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.
1. The team with the most wins is ranked high
2. If the number of wins is the same, the team with the fewest losses will be ranked higher.
Create a program that inputs the results of each team and outputs the team names in order from the top team. If there are teams with the same rank, output them in the order of input. However, the number of teams n is an integer from 2 to 10 and the team name t is a single-byte alphabetic character. , 2 for a draw. Also, the team name shall be unique.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
n
score1
score2
::
scoren
The number of teams n (2 ≤ n ≤ 10) is given on the first line, and the scorei of the i-th team is given on the following n lines. Each grade is given in the following format.
t r1 r2 ... rn−1
The team name t (one-character half-width alphabetic character) and the result ri (0, 1, or 2) for each match of t are given separated by blanks.
The number of datasets does not exceed 50.
Output
For each dataset, the team name is output in order from the top team.
Example
Input
6
A 1 0 0 2 0
B 0 0 1 1 0
C 1 1 1 1 1
D 1 0 0 1 2
E 2 0 0 0 0
F 1 1 0 2 1
4
g 1 1 1
h 0 1 2
w 0 0 0
b 0 2 1
0
Output
E
A
B
D
F
C
w
h
b
g
Submitted Solution:
```
def parse(i):
l = input().strip().split()
m = l.pop(0)
return (-l.count('0'), l.count('1'), i, m)
n = int(input())
while n:
print('\n'.join(str(t[3]) for t in sorted([parse(_) for _ in range(n)])))
n = int(input())
``` | instruction | 0 | 81,626 | 17 | 163,252 |
Yes | output | 1 | 81,626 | 17 | 163,253 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.