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.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sab... | instruction | 0 | 43,308 | 12 | 86,616 |
Tags: combinatorics, math
Correct Solution:
```
MOD = 10**9+7
n = int(input())
notUsed = set(range(1, n+1))
chairs = set()
for i, a in enumerate(map(int, input().split()), 1):
if a == -1:
chairs.add(i)
else:
notUsed -= {a}
fixed = len(chairs & notUsed)
m = len(notUsed)
U = m
fact = [0]*(U+1)
f... | output | 1 | 43,308 | 12 | 86,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sab... | instruction | 0 | 43,309 | 12 | 86,618 |
Tags: combinatorics, math
Correct Solution:
```
MOD = 10**9+7
def solve(values):
notUsed = set(range(1, len(values)+1))
chairs = set()
for i, a in enumerate(values, 1):
if a == -1:
chairs.add(i)
else:
notUsed -= {a}
fixed = len(chairs & notUsed)
m = len(notU... | output | 1 | 43,309 | 12 | 86,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sab... | instruction | 0 | 43,310 | 12 | 86,620 |
Tags: combinatorics, math
Correct Solution:
```
def fact(x):
ans=1
for i in range(2,x+1):
ans*=i
return ans
n=int(input())
a=[int(x) for x in input().split()]
s=set(a)
x=0
y=0
for i in range(1,n+1):
if a[i-1]==-1:
g=i in s
(x,y)=(x+1-g,y+g)
otv=fact(x+y)
currf=fact... | output | 1 | 43,310 | 12 | 86,621 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sab... | instruction | 0 | 43,311 | 12 | 86,622 |
Tags: combinatorics, math
Correct Solution:
```
input()
t = list(map(int, input().split()))
s, m = 0, 1000000007
p = {i for i, q in enumerate(t, 1) if q == -1}
n, k = len(p), len(p - set(t))
d, c = 2 * (n & 1) - 1, 1
for j in range(n + 1):
d = -d * max(1, j) % m
if n - j <= k:
s += c * d
c = c *... | output | 1 | 43,311 | 12 | 86,623 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sab... | instruction | 0 | 43,312 | 12 | 86,624 |
Tags: combinatorics, math
Correct Solution:
```
def fact(x):
ans=1
for i in range(2,x+1):
ans*=i
return ans
n=int(input())
a=[int(x) for x in input().split()]
s=set(a)
x=0
y=0
for i in range(1,n+1):
if a[i-1]==-1:
if i in s:
y+=1
else:
x+=1
otv = fact(x + ... | output | 1 | 43,312 | 12 | 86,625 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sab... | instruction | 0 | 43,313 | 12 | 86,626 |
Tags: combinatorics, math
Correct Solution:
```
MOD = 10**9+7
n = int(input())
notUsed = set(range(1, n+1))
chairs = set()
for i, a in enumerate(map(int, input().split()), 1):
if a == -1:
chairs.add(i)
else:
notUsed -= {a}
fixed = len(chairs & notUsed)
m = len(notUsed)
fact = [0]*(m+1)
fact[0... | output | 1 | 43,313 | 12 | 86,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub ... | instruction | 0 | 43,314 | 12 | 86,628 |
Yes | output | 1 | 43,314 | 12 | 86,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub ... | instruction | 0 | 43,315 | 12 | 86,630 |
Yes | output | 1 | 43,315 | 12 | 86,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub ... | instruction | 0 | 43,316 | 12 | 86,632 |
No | output | 1 | 43,316 | 12 | 86,633 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub ... | instruction | 0 | 43,317 | 12 | 86,634 |
No | output | 1 | 43,317 | 12 | 86,635 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub ... | instruction | 0 | 43,318 | 12 | 86,636 |
No | output | 1 | 43,318 | 12 | 86,637 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub ... | instruction | 0 | 43,319 | 12 | 86,638 |
No | output | 1 | 43,319 | 12 | 86,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,343 | 12 | 86,686 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
INF = 10 ** 10
def merge(l, r):
res = l + r
i = j = k = 0
while i < len(l) and j < len(r):
if l[i] < r[j]:
res[k] = l[i]
k += 1
i += 1
else:
res[k] = r[j]
... | output | 1 | 43,343 | 12 | 86,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,344 | 12 | 86,688 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
class SegTree:
def __init__(self, arr = None, length = None):
"""
Creates a segment tree. If arr (a list) is given, length is ignored,
and we build a segment tree with underlying array arr. If no list is
given,... | output | 1 | 43,344 | 12 | 86,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,345 | 12 | 86,690 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode ... | output | 1 | 43,345 | 12 | 86,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,346 | 12 | 86,692 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
BIT = [0]*(10**6)
def update(idx):
while(idx < len(BIT)):
BIT[idx] += 1
idx += idx & -idx
def query(idx):
s = 0
while(idx > 0):
s += BIT[idx]
idx -= idx & -idx
return s
n = int(input())
a = list(map(int, input().split()... | output | 1 | 43,346 | 12 | 86,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,347 | 12 | 86,694 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
INF = 10 ** 10
def merge(l, r):
res = l + r
i = j = k = 0
while i < len(l) and j < len(r):
if l[i] < r[j]:
res[k] = l[i]
k += 1
i += 1
else:
res[k] = r[j]
... | output | 1 | 43,347 | 12 | 86,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,348 | 12 | 86,696 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
import sys
input = sys.stdin.readline
n = int(input())
t= list(map(int,input().split()))
d = dict()
j = 0
prefix =[]
while j <=n-1:
if t[j] not in d:
d[t[j]]=1
else:
d[t[j]]+=1
prefix.append(d[t[j]])
... | output | 1 | 43,348 | 12 | 86,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,349 | 12 | 86,698 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
n=int(input())
def getsum(BITTree,i):
s = 0 #initialize result
# index in BITree[] is 1 more than the index in arr[]
i = i+1
# Traverse ancestors of BITree[index]
while i > 0:
# Add current element of BIT... | output | 1 | 43,349 | 12 | 86,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,350 | 12 | 86,700 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
n = int(input())
l = [int(j) for j in input().split()]
d = dict()
pre = []
for i in range(n):
if l[i] in d:
d[l[i]]+=1
else:
d[l[i]]=1
pre.append(d[l[i]])
suf = [0 for i in range(n)]
d = dict()
for i in range(n-1, -1, -1):
if l[i] in d:
... | output | 1 | 43,350 | 12 | 86,701 |
Provide tags and a correct Python 2 solution for this coding contest problem.
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that cons... | instruction | 0 | 43,351 | 12 | 86,702 |
Tags: data structures, divide and conquer, sortings
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
return map... | output | 1 | 43,351 | 12 | 86,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,380 | 12 | 86,760 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
def calc(n, k):
if n == 1:
print(1)
else:
#n, k = map(int,input().split())
tot = [0] * (n + 1)
tot[n] = 1
tot[n - 1] = 1
tot[n - 2] = 2
for i i... | output | 1 | 43,380 | 12 | 86,761 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,381 | 12 | 86,762 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
'''def f(n):
n = [i-1 for i in n]
a = []
while max(n) >= 0:
for i in range(len(n)-1,-1,-1):
if n[i] != -1:
break
k = [i]
while n[k[-1]] != -1:
... | output | 1 | 43,381 | 12 | 86,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,382 | 12 | 86,764 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
n, k = list(map(int, input().split()))
#n = int(input())
#k = int(input())
fib = [0] * (n + 1)
fib[0] = 1
fib[1] = 1
res = [0] * n
for i in range(2, n):
fib[i] = fib[i - 1] + fib[i - 2]
idx = 0
while idx ... | output | 1 | 43,382 | 12 | 86,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,383 | 12 | 86,766 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
l = [1, 2]
for i in range(1, 100):
l.append(l[i]+l[i-1])
if l[-1]>10**18:
break
l = [0, 0] + l
def perm(n, k):
if n == 1 and k == 1:
return [1]
if n == 2 and k == 1:
r... | output | 1 | 43,383 | 12 | 86,767 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,384 | 12 | 86,768 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
#!/usr/bin/python3
arr = [1] * 51
for i in range(2, 51):
arr[i] = arr[i - 1] + arr[i - 2]
ans = []
def generate(i, n, to):
if i == n:
assert to == 1
print(" ".join(map(str, ans)))... | output | 1 | 43,384 | 12 | 86,769 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,385 | 12 | 86,770 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
n, k = map(int, input().split())
f = [1, 1]
for i in range(2, n):
f.append(f[i-2] + f[i-1])
i = n
while i > 0:
i -= 1
if k > f[i]:
print(n - i + 1, n - i, end = ' ')
k -= f[i]
... | output | 1 | 43,385 | 12 | 86,771 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,386 | 12 | 86,772 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
def getFibCode(x):
result = []
f =[1, 1]
while f[-2] + f[-1] <= x:
f.append(f[-2] + f[-1])
for i in f[:0:-1]:
if i <= x:
result.append(1)
x -= i
... | output | 1 | 43,386 | 12 | 86,773 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Oot... | instruction | 0 | 43,387 | 12 | 86,774 |
Tags: binary search, combinatorics, constructive algorithms, greedy, implementation, math
Correct Solution:
```
from bisect import bisect_left
n, k = map(int, input().split())
l = [1, 1, 2]
for i in range(90):
l.append(l[-1] + l[-2])
ps = []
left = k
while left > 0:
nu = bisect_left(l, left)
if nu-1 >= 1:... | output | 1 | 43,387 | 12 | 86,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,388 | 12 | 86,776 |
Yes | output | 1 | 43,388 | 12 | 86,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,389 | 12 | 86,778 |
Yes | output | 1 | 43,389 | 12 | 86,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,390 | 12 | 86,780 |
Yes | output | 1 | 43,390 | 12 | 86,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,391 | 12 | 86,782 |
Yes | output | 1 | 43,391 | 12 | 86,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,392 | 12 | 86,784 |
No | output | 1 | 43,392 | 12 | 86,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,393 | 12 | 86,786 |
No | output | 1 | 43,393 | 12 | 86,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,394 | 12 | 86,788 |
No | output | 1 | 43,394 | 12 | 86,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, ... | instruction | 0 | 43,395 | 12 | 86,790 |
No | output | 1 | 43,395 | 12 | 86,791 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,863 | 12 | 87,726 |
Tags: math
Correct Solution:
```
n = int(input())
m = list(map(int,input().split()))
perm = [0 for _ in range(n)]
for i in range(1,n):
perm[i]=perm[i-1]+m[i-1]
x = perm[::]
x.sort()
val = 1-x[0]
x=[x[i]+val for i in range(n)]
if x==[i+1 for i in range(n)]:
perm=[perm[i]+val for i in range(n)]
for elem in ... | output | 1 | 43,863 | 12 | 87,727 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,864 | 12 | 87,728 |
Tags: math
Correct Solution:
```
from itertools import*
n=int(input())
a=[0,*accumulate(map(int,input().split()))]
m=min(a)
if set(a)==set(range(m,m+n)):print(*(x-m+1for x in a))
else:print(-1)
``` | output | 1 | 43,864 | 12 | 87,729 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,865 | 12 | 87,730 |
Tags: math
Correct Solution:
```
def solve(n, q):
x = 0
ans = [x]
max_p = x
max_i = 0
for i, d in enumerate(q):
p = ans[i] + d
if p > max_p:
max_p = p
max_i = i + 1
ans.append(p)
diff = n - ans[max_i]
used = [0 for i in range(n)]
for ... | output | 1 | 43,865 | 12 | 87,731 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,866 | 12 | 87,732 |
Tags: math
Correct Solution:
```
n = int(input())
q = list(map(int, input().split()))
a = [0] * n
a[0] = 1
for i in range(1, n):
a[i] = q[i - 1] + a[i - 1]
m = min(a)
d = 1 - m
if d > 0:
for i in range(n):
a[i] += d
used = [0] * n
for i in a:
if i > n or used[i - 1]:
print(-1)
exit(0... | output | 1 | 43,866 | 12 | 87,733 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,867 | 12 | 87,734 |
Tags: math
Correct Solution:
```
n = int(input())
q = list(map(int, input().split()))
s = n*(n+1)//2
for i in range(n-1):
s -= (n-1-i)*q[i]
if s%n!=0:
print(-1)
exit()
p1 = s//n
if p1<1 or n<p1:
print(-1)
exit()
se = set()
se.add(p1)
p = [p1]
for i in range(n-1):
np = p[-1]+q[i]
... | output | 1 | 43,867 | 12 | 87,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,868 | 12 | 87,736 |
Tags: math
Correct Solution:
```
from itertools import accumulate
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a=list(accumulate(a))
x=1-min(a)
for _ in range(len(a)):
a[_]+=x
y=0
for _ in range(len(a)):
if a[_]<=n:
y+=1
if y==n and len(list(set(a)))==n:
print(*a)
else:
print(-1... | output | 1 | 43,868 | 12 | 87,737 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,869 | 12 | 87,738 |
Tags: math
Correct Solution:
```
n = int(input())
q = list(map(int, input().split()))
p = list(range(n))
p[0] = 0
minp = 0
for i in range(1, n):
p[i] = q[i - 1] + p[i - 1]
if p[i] < minp:
minp = p[i]
minp = -minp
for i in range(n):
p[i] += minp + 1
sp = sorted(p)
if sp[0] != 1:
print(-1)
else:
... | output | 1 | 43,869 | 12 | 87,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays a... | instruction | 0 | 43,870 | 12 | 87,740 |
Tags: math
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
mn = 0
sm = 0
for i in range(0, n-1):
sm += a[i]
mn = min(mn, sm)
start = -mn+1
used = [0]*(n+1)
ans = []
for i in range(n-1):
if start > n or start <= 0:
print(-1)
exit(0)
if used[start] == 1:
... | output | 1 | 43,870 | 12 | 87,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3,... | instruction | 0 | 43,871 | 12 | 87,742 |
Yes | output | 1 | 43,871 | 12 | 87,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3,... | instruction | 0 | 43,872 | 12 | 87,744 |
Yes | output | 1 | 43,872 | 12 | 87,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3,... | instruction | 0 | 43,873 | 12 | 87,746 |
Yes | output | 1 | 43,873 | 12 | 87,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3,... | instruction | 0 | 43,874 | 12 | 87,748 |
Yes | output | 1 | 43,874 | 12 | 87,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3,... | instruction | 0 | 43,875 | 12 | 87,750 |
No | output | 1 | 43,875 | 12 | 87,751 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.