message stringlengths 2 433k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 113 108k | cluster float64 12 12 | __index_level_0__ int64 226 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,303 | 12 | 8,606 |
Tags: math, number theory, probabilities
Correct Solution:
```
import random
# Sieve
sieve_primes = []
PRIME_LIMIT = int(1e6)
sieve = [False for i in range(0,PRIME_LIMIT)]
for i in range(2,PRIME_LIMIT):
if not sieve[i]:
sieve_primes.append(i)
for j in range(i*i, PRIME_LIMIT, i):
sieve[j... | output | 1 | 4,303 | 12 | 8,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,304 | 12 | 8,608 |
Tags: math, number theory, probabilities
Correct Solution:
```
import sys
input = sys.stdin.readline
from math import sqrt
import random
n=int(input())
A=list(map(int,input().split()))
random.shuffle(A)
MOD={2,3,5}
for t in A[:31]:
for x in [t-1,t,t+1]:
if x<=5:
continue
L=int(sqrt(x)... | output | 1 | 4,304 | 12 | 8,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,305 | 12 | 8,610 |
Tags: math, number theory, probabilities
Correct Solution:
```
import random
n = int(input())
a = [int(x) for x in input().split()]
can = set()
ls = []
for i in range(10):
idx = random.randint(0, n - 1)
for c in range(-1, 2):
if a[idx] + c > 0: ls.append(a[idx] + c)
maxn = 1000001
prime = []
vis = [Tru... | output | 1 | 4,305 | 12 | 8,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,306 | 12 | 8,612 |
Tags: math, number theory, probabilities
Correct Solution:
```
import sys
input = sys.stdin.readline
from math import sqrt
n=int(input())
A=list(map(int,input().split()))
SA=sorted(set(A))
MOD={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 12... | output | 1 | 4,306 | 12 | 8,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,307 | 12 | 8,614 |
Tags: math, number theory, probabilities
Correct Solution:
```
import random
n = int(input())
a = list(map(int, input().split()))
limit = min(8, n)
iterations = [x for x in range(n)]
random.shuffle(iterations)
random.shuffle(iterations)
iterations = iterations[:limit]
def factorization(x):
primes = []
i = 2
wh... | output | 1 | 4,307 | 12 | 8,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,308 | 12 | 8,616 |
Tags: math, number theory, probabilities
Correct Solution:
```
import random
n = int(input())
a = list(map(int, input().split()))
limit = min(8, n)
iterations = [x for x in range(n)]
random.shuffle(iterations)
iterations = iterations[:limit]
def factorization(x):
primes = []
i = 2
while i * i <= x:
if x % i == ... | output | 1 | 4,308 | 12 | 8,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,309 | 12 | 8,618 |
Tags: math, number theory, probabilities
Correct Solution:
```
import random
# Sieve
sieve_primes = []
PRIME_LIMIT = int(1e6)
sieve = [False for i in range(0,PRIME_LIMIT)]
for i in range(2,PRIME_LIMIT):
if not sieve[i]:
sieve_primes.append(i)
for j in range(i*i, PRIME_LIMIT, i):
sieve[j... | output | 1 | 4,309 | 12 | 8,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An operation consists of choosing an element and eith... | instruction | 0 | 4,310 | 12 | 8,620 |
Tags: math, number theory, probabilities
Correct Solution:
```
import random
n = int(input())
a = list(map(int, input().split()))
primes = set()
for x in random.choices(a, k=min(n, 30)):
for y in (x-1, x, x+1):
d = 2
while d * d <= y:
while y % d == 0:
primes.add(d)
... | output | 1 | 4,310 | 12 | 8,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,311 | 12 | 8,622 |
Yes | output | 1 | 4,311 | 12 | 8,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,312 | 12 | 8,624 |
Yes | output | 1 | 4,312 | 12 | 8,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,313 | 12 | 8,626 |
Yes | output | 1 | 4,313 | 12 | 8,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,314 | 12 | 8,628 |
Yes | output | 1 | 4,314 | 12 | 8,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,315 | 12 | 8,630 |
No | output | 1 | 4,315 | 12 | 8,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,316 | 12 | 8,632 |
No | output | 1 | 4,316 | 12 | 8,633 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,317 | 12 | 8,634 |
No | output | 1 | 4,317 | 12 | 8,635 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:
You have an array a consisting of n positive integers. An ope... | instruction | 0 | 4,318 | 12 | 8,636 |
No | output | 1 | 4,318 | 12 | 8,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
Input
The first line contains the in... | instruction | 0 | 4,336 | 12 | 8,672 |
Tags: brute force, implementation
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
s=s/n
if s%1!=0:
print("0")
exit()
else:
l=[]
g=0
for i in range(n):
if a[i]==s:
g=g+1
l.append(i+1)
print(g)
for i in range(g):
print(l[i],end=" ")
``` | output | 1 | 4,336 | 12 | 8,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
Input
The first line contains the in... | instruction | 0 | 4,337 | 12 | 8,674 |
Tags: brute force, implementation
Correct Solution:
```
n = int(input())
A = list(map(int, input().split()))
B = []
srar = 0
for i in range(n):
srar += A[i]
srar = srar/n
for i in range(n):
if ((srar * n) - A[i]) / (n-1) == A[i]:
B.append(i+1)
print(len(B))
for i in range(len(B)):... | output | 1 | 4,337 | 12 | 8,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
Input
The first line contains the in... | instruction | 0 | 4,338 | 12 | 8,676 |
Tags: brute force, implementation
Correct Solution:
```
N = int(input())
ar = [int(x) for x in input().split()]
ans = []
s = sum(ar)
for i, j in enumerate(ar):
if j * N == s:
ans.append(str(i + 1))
print(len(ans))
print(' '.join(ans))
``` | output | 1 | 4,338 | 12 | 8,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
Input
The first line contains the in... | instruction | 0 | 4,339 | 12 | 8,678 |
Tags: brute force, implementation
Correct Solution:
```
#!/usr/bin/env python3
n = int(input())
arr = [int(i) for i in input().split(' ')]
s = 0
result = []
for item in arr:
s += item
s = s/n
count = 0
pos = 1
for item in arr:
if item == s:
count += 1
result.append(str(pos))
pos += 1
pr... | output | 1 | 4,339 | 12 | 8,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
Input
The first line contains the in... | instruction | 0 | 4,340 | 12 | 8,680 |
Tags: brute force, implementation
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
count = 0
ind = []
total = sum(a)
for i in range(n):
if a[i]==(total-a[i])/(n-1):
count+=1
ind.append(i+1)
print(count)
print(*ind)
``` | output | 1 | 4,340 | 12 | 8,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An n Γ n square matrix is special, if:
* it is binary, that is, each cell contains either a 0, or a 1;
* the number of ones in each row and column equals 2.
You are given n and the first m rows of the matrix. Print the number of sp... | instruction | 0 | 4,588 | 12 | 9,176 |
Tags: combinatorics, dp
Correct Solution:
```
n, m, mod = [int(x) for x in input().split()]
from functools import lru_cache
import sys
sys.setrecursionlimit(100000000)
@lru_cache(maxsize=None)
def rec(twos, ones):
global mod
if twos == 0 and ones == 0:
return 1
if twos == 1 and ones == 0:
... | output | 1 | 4,588 | 12 | 9,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment.
The teacher gave Andrew an array of n numbers a1, ... | instruction | 0 | 4,598 | 12 | 9,196 |
Tags: brute force, data structures, math, sortings
Correct Solution:
```
import sys
def myargsort(a):
b = list(zip(a, range(0, len(a))))
b.sort()
r = [pr[1] for pr in b]
return r
fin = sys.stdin
n = int(fin.readline())
a = [int(number) for number in fin.readline().split()]
p = myargsort(a)
p.reverse()... | output | 1 | 4,598 | 12 | 9,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,651 | 12 | 9,302 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
from heapq import heappush, heappop
from sys import stdin
heap = []
L = []
n, *l = stdin.read().splitlines()
for string in l:
array = string.split()
if array[0] == 'insert':
heappush(heap, int(array[1]))
elif array[0] == '... | output | 1 | 4,651 | 12 | 9,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,652 | 12 | 9,304 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
from heapq import *
numLines = int(input())
heap = []
output_ops = []
for _ in range(numLines):
opString = input()
operation = opString.split()
if operation[0] == "insert":
heappush(heap, int(operation[1]))
if opera... | output | 1 | 4,652 | 12 | 9,305 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,653 | 12 | 9,306 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
import heapq
n = int(input())
m = n
operations = []
heap = []
for i in range(n):
s = input()
a = s.split()
if a[0] == 'insert':
heapq.heappush(heap, int(a[1]))
elif a[0] == 'removeMin':
if heap:
h... | output | 1 | 4,653 | 12 | 9,307 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,654 | 12 | 9,308 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
import heapq
m = int(input())
heap = []
ans = []
for i in range(m):
a = input()
if a == 'removeMin':
if heap == []:
heapq.heappush(heap, 1)
heapq.heappop(heap)
ans.append('insert 1')
... | output | 1 | 4,654 | 12 | 9,309 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,655 | 12 | 9,310 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
import heapq
n = int(input())
commands = []
arr = []
for i in range(n):
s = input()
tmp = s.split(' ')
if tmp[0] == "insert":
heapq.heappush(arr, int(tmp[1]))
elif tmp[0] == "removeMin":
if not len(arr):
... | output | 1 | 4,655 | 12 | 9,311 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,656 | 12 | 9,312 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
from sys import stdin
from bisect import bisect_left
n = int(stdin.readline())
heap = []
res = []
for i in range(n):
string = stdin.readline()
oper = string.split()
if oper[0][0] == 'i':
key = int(oper[1])
pos = bi... | output | 1 | 4,656 | 12 | 9,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,657 | 12 | 9,314 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
import heapq
def inp(n):
L = []
for i in range(n):
s = str(input())
s1 = s.split()
if len(s1) == 2:
L.append([s1[0],int(s1[1])])
else:
L.append(s1)
return L
n = int(input()... | output | 1 | 4,657 | 12 | 9,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract ... | instruction | 0 | 4,658 | 12 | 9,316 |
Tags: constructive algorithms, data structures, greedy
Correct Solution:
```
from __future__ import division, print_function
import heapq
import math
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.bu... | output | 1 | 4,658 | 12 | 9,317 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,659 | 12 | 9,318 |
Yes | output | 1 | 4,659 | 12 | 9,319 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,660 | 12 | 9,320 |
Yes | output | 1 | 4,660 | 12 | 9,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,661 | 12 | 9,322 |
Yes | output | 1 | 4,661 | 12 | 9,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,662 | 12 | 9,324 |
Yes | output | 1 | 4,662 | 12 | 9,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,663 | 12 | 9,326 |
No | output | 1 | 4,663 | 12 | 9,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,664 | 12 | 9,328 |
No | output | 1 | 4,664 | 12 | 9,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,665 | 12 | 9,330 |
No | output | 1 | 4,665 | 12 | 9,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of... | instruction | 0 | 4,666 | 12 | 9,332 |
No | output | 1 | 4,666 | 12 | 9,333 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,767 | 12 | 9,534 |
Tags: brute force, constructive algorithms
Correct Solution:
```
n, a, b = map(int, input().strip().split())
def pp(seq):
return ' '.join(map(str, seq))
def cycle(start, size):
return list(range(start+1, start+size)) + [start]
def fail_sequence(target, acc=[]):
''' recursion failure, bloody python '''
... | output | 1 | 4,767 | 12 | 9,535 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,768 | 12 | 9,536 |
Tags: brute force, constructive algorithms
Correct Solution:
```
N, A, B = map(int, input().split())
for i in range(N//A+1):
if (N-i*A)%B==0:
ans = []
for j in range(i):
l = []
for k in range(1, A+1):
l.append(j*A+k)
... | output | 1 | 4,768 | 12 | 9,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,769 | 12 | 9,538 |
Tags: brute force, constructive algorithms
Correct Solution:
```
n, a, b = map(int, input().split())
x, y = 0, 0
ok = False
for i in range(n // a + 1):
if (n - a * i) % b == 0:
ok = True
x, y = i, (n - a * i) // b
break
if not ok:
print(-1)
exit()
pos = 1
for i in range(x):
print... | output | 1 | 4,769 | 12 | 9,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,770 | 12 | 9,540 |
Tags: brute force, constructive algorithms
Correct Solution:
```
ans = []
def go(base, n):
ans.append(base + n - 1)
for i in range(base, base + n - 1):
ans.append(i)
def solve(n, a, b, x):
cur_start = 1
y = (n - a * x) // b
for i in range(x):
go(cur_start, a)
cur_start += ... | output | 1 | 4,770 | 12 | 9,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,771 | 12 | 9,542 |
Tags: brute force, constructive algorithms
Correct Solution:
```
n,a,b=map(int,input().split())
x,y=-1,-1
for i in range(n+1):
if n-a*i>=0 and (n-a*i)%b==0:
x=i
y=(n-a*i)//b
break
if x==-1:
print(-1)
exit()
ans=[-1]*n
for i in range(0,a*x,a):
for j in range(i,i+a-1):
ans[j]=j+1
ans[i+a-1]=i
fo... | output | 1 | 4,771 | 12 | 9,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,772 | 12 | 9,544 |
Tags: brute force, constructive algorithms
Correct Solution:
```
n, a, b = map(int, input().split())
r = []
def f(a, l, r=r):
r += [a + l - 1] + list(range(a, a + l - 1))
i = 1
while n > 0:
if n % b is 0:
break
f(i, a)
i += a
n -= a
while n > 0:
f(i, b)
i += b
n -= b
print(-1) i... | output | 1 | 4,772 | 12 | 9,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,773 | 12 | 9,546 |
Tags: brute force, constructive algorithms
Correct Solution:
```
#!/usr/bin/env python3
import sys
n, a, b = map(int, sys.stdin.readline().strip().split())
# supposed a>=0, b>=0, a+b>0
# returns (d, p, q) where d = gcd(a, b) = a*p + b*q
def euc(a, b):
if b > a:
(d, p, q) = euc(b, a)
return (d, q,... | output | 1 | 4,773 | 12 | 9,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.
For given N, A, B, find a permutation P of ... | instruction | 0 | 4,774 | 12 | 9,548 |
Tags: brute force, constructive algorithms
Correct Solution:
```
# ========= /\ /| |====/|
# | / \ | | / |
# | /____\ | | / |
# | / \ | | / |
# ========= / \ ===== |/====|
# code
def main():
n , a , b = map(int , input(... | output | 1 | 4,774 | 12 | 9,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist... | instruction | 0 | 4,775 | 12 | 9,550 |
Yes | output | 1 | 4,775 | 12 | 9,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist... | instruction | 0 | 4,776 | 12 | 9,552 |
Yes | output | 1 | 4,776 | 12 | 9,553 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
<image>
Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exist... | instruction | 0 | 4,777 | 12 | 9,554 |
Yes | output | 1 | 4,777 | 12 | 9,555 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.