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.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (... | instruction | 0 | 96,499 | 12 | 192,998 |
Tags: greedy, sortings
Correct Solution:
```
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
n,=I()
l=I()
an=[]
sv=[0]*(10**5+10)
for i in range(2,len(sv)):
if not sv[i]:
sv[i]=i
for j in range(2*i,len(sv),i):
sv[j]=1
sv[0]=sv[1]=1
for i in range(2,len(sv)):
if not sv[i]-1:
... | output | 1 | 96,499 | 12 | 192,999 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (... | instruction | 0 | 96,500 | 12 | 193,000 |
Tags: greedy, sortings
Correct Solution:
```
# from random import shuffle
# f = open("out.txt", "w")
# n = 1000
# test = list(range(1, n + 1))
# shuffle(test)
# print(n, file=f)
# print(' '.join(map(str, test)), file=f)
from bisect import *
from sys import stdin
f = stdin # open("out.txt", "r")
n = int(f.readline()... | output | 1 | 96,500 | 12 | 193,001 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (... | instruction | 0 | 96,501 | 12 | 193,002 |
Tags: greedy, sortings
Correct Solution:
```
import bisect
def gen_primes(upper_bound):
upper_bound += 1
t = [0] * (upper_bound)
primes = [2]
for i in range(3, upper_bound, 2):
if t[i]:
continue
primes.append(i)
for j in range(i + i, upper_bound, i):
t[j... | output | 1 | 96,501 | 12 | 193,003 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (... | instruction | 0 | 96,502 | 12 | 193,004 |
Tags: greedy, sortings
Correct Solution:
```
import sys
import collections as cc
import bisect as bi
input=sys.stdin.readline
I=lambda:list(map(int,input().split()))
pr=[]
N=10**6+3
ss=[0]*(N)
ss[0]=1
for i in range(2,N):
if ss[i]==0:
ss[i]=i
pr.append(i)
for j in range(2*i,N,i):
ss[j]=i
n,=I()
l=I()
f={}
ans... | output | 1 | 96,502 | 12 | 193,005 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (... | instruction | 0 | 96,503 | 12 | 193,006 |
Tags: greedy, sortings
Correct Solution:
```
from sys import stdin, stdout, setrecursionlimit
from gc import disable
from bisect import bisect_right
#stdin = open("input.txt","r")
#stdout = open("output.txt","w")
#setrecursionlimit((1<<31)-1)
gets = input
puts = print
data = iter(stdin.read().split('\n'))
inp... | output | 1 | 96,503 | 12 | 193,007 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
* choose two indexes, i and j (... | instruction | 0 | 96,504 | 12 | 193,008 |
Tags: greedy, sortings
Correct Solution:
```
import bisect
def gen_primes(upper_bound):
upper_bound += 1
t = [0] * (upper_bound)
primes = [2]
for i in range(3, upper_bound, 2):
if t[i]:
continue
primes.append(i)
for j in range(i + i, upper_bound, i):
... | output | 1 | 96,504 | 12 | 193,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,505 | 12 | 193,010 |
Yes | output | 1 | 96,505 | 12 | 193,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,506 | 12 | 193,012 |
Yes | output | 1 | 96,506 | 12 | 193,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,507 | 12 | 193,014 |
Yes | output | 1 | 96,507 | 12 | 193,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,508 | 12 | 193,016 |
Yes | output | 1 | 96,508 | 12 | 193,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,509 | 12 | 193,018 |
No | output | 1 | 96,509 | 12 | 193,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,510 | 12 | 193,020 |
No | output | 1 | 96,510 | 12 | 193,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,511 | 12 | 193,022 |
No | output | 1 | 96,511 | 12 | 193,023 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it mult... | instruction | 0 | 96,512 | 12 | 193,024 |
No | output | 1 | 96,512 | 12 | 193,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,654 | 12 | 193,308 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=0
s=0
v=[False]*n
for i in range (n):
if v[i]:
continue
k+=1
while not v[i]:
v[i]=True
i=a[i]-1
if k==1:
k=0
else:
s+=k
if s... | output | 1 | 96,654 | 12 | 193,309 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,655 | 12 | 193,310 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
from collections import deque
def read(type=int):
return type(input())
def read_arr(type=int):
return [type(token) for token in input().split()]
def num_cycles(P):
V = [False] * len(P)
i = 0
for u in P:
if not V[u]:
... | output | 1 | 96,655 | 12 | 193,311 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,656 | 12 | 193,312 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
n = int(input())
p = map(int, input().split())
p = [x - 1 for x in p]
b = map(int, input().split())
s = int(sum(b))
c = 0
done = set()
for i in range(n):
if i not in done:
c += 1
j = i
while j not in done:
done... | output | 1 | 96,656 | 12 | 193,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,657 | 12 | 193,314 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
read = lambda: map(int, input().split())
n = int(input())
p = list(read())
b = list(read())
ans = (b.count(1) + 1) % 2
was = [0] * n
cnt = 0
for i in range(n):
if not was[i]:
cnt += 1
v = i
while not was[v]:
... | output | 1 | 96,657 | 12 | 193,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,658 | 12 | 193,316 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
if __name__ == '__main__':
n, = map(int, input().split())
p = list(map(lambda x: int(x)-1, input().split()))
swaps = sum(map(int, input().split()))
res = 1 - (swaps % 2)
visited = [False for _ in range(n)]
cycles = 0
for i in range(n):
if vi... | output | 1 | 96,658 | 12 | 193,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,659 | 12 | 193,318 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
n = int(input())
p = list(map(int, input().split()))
b = list(map(int, input().split()))
visited = [False] * n
loops = 0
for i in range(n):
if visited[i]:
continue
loops += 1
while not visited[i]:
visited[i] = True
... | output | 1 | 96,659 | 12 | 193,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,660 | 12 | 193,320 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
n = int(input())
p = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt_cyc = 0
vis = [0] * n
for i in range(n):
if vis[i] == 0:
vis[i] = 1
nxt = p[i]-1
while vis[nxt] == 0:
vis[nxt] = 1
... | output | 1 | 96,660 | 12 | 193,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the... | instruction | 0 | 96,661 | 12 | 193,322 |
Tags: constructive algorithms, dfs and similar
Correct Solution:
```
import sys
def main():
n = int(sys.stdin.readline())
p = list(map(int,sys.stdin.readline().split()))
b = list(map(int,sys.stdin.readline().split()))
for i in range(n):
p[i]=p[i]-1
cur = 0
res = 0
while cur < n:... | output | 1 | 96,661 | 12 | 193,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,662 | 12 | 193,324 |
Yes | output | 1 | 96,662 | 12 | 193,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,663 | 12 | 193,326 |
Yes | output | 1 | 96,663 | 12 | 193,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,664 | 12 | 193,328 |
Yes | output | 1 | 96,664 | 12 | 193,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,665 | 12 | 193,330 |
Yes | output | 1 | 96,665 | 12 | 193,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,666 | 12 | 193,332 |
No | output | 1 | 96,666 | 12 | 193,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,667 | 12 | 193,334 |
No | output | 1 | 96,667 | 12 | 193,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,668 | 12 | 193,336 |
No | output | 1 | 96,668 | 12 | 193,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: i... | instruction | 0 | 96,669 | 12 | 193,338 |
No | output | 1 | 96,669 | 12 | 193,339 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,992 | 12 | 193,984 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
# 注ζarray cacheι εΊ QQ
from math import log, floor
"""
class RMQ:
'''
maximum version rmq
query: max([l, r])
'''
def __init__(self, nums):
size = floor(log(len(nums)) // log(2)) + 1
self.nums = [nums]
... | output | 1 | 96,992 | 12 | 193,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,993 | 12 | 193,986 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
import os
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
def input_as_list():
return list(map(int, input().split()))
def array_of(f, *dim):
return [array_of(f, *dim[1:]) for _ in range(dim... | output | 1 | 96,993 | 12 | 193,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,994 | 12 | 193,988 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
# 注ζarray cacheι εΊ QQ
from math import log, floor
class RMQ:
'''
maximum version rmq
query: max([l, r])
'''
def __init__(self, nums):
size = floor(log(len(nums)) // log(2)) + 1
self.nums = [nums]
... | output | 1 | 96,994 | 12 | 193,989 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,995 | 12 | 193,990 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
import sys
class segmentTree:
def __init__(self, n):
self.n = n
self.seg = [self.n + 1] * (self.n << 1)
def update(self, p, value):
p += self.n
self.seg[p] = value
while p > 1:
p >>= 1
self.seg[p] = min(self.seg[p * 2],... | output | 1 | 96,995 | 12 | 193,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,996 | 12 | 193,992 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
import sys
N, M, Q = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
k = N.bit_length()
bef = [-2]*(N+1)
for p, q in zip(P[1:]+[P[0]], P):
bef[p] = q... | output | 1 | 96,996 | 12 | 193,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,997 | 12 | 193,994 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
# 注ζarray cacheι εΊ QQ
from math import log, floor
import sys
"""
class RMQ:
'''
maximum version rmq
query: max([l, r])
'''
def __init__(self, nums):
size = floor(log(len(nums)) // log(2)) + 1
self.nums... | output | 1 | 96,997 | 12 | 193,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,998 | 12 | 193,996 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
from math import log, floor
import sys
class RMQ:
'''
maximum version rmq
query: max([l, r])
'''
def __init__(self, nums):
size = floor(log(len(nums)) // log(2)) + 1
self.nums = [nums]
... | output | 1 | 96,998 | 12 | 193,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each o... | instruction | 0 | 96,999 | 12 | 193,998 |
Tags: data structures, dfs and similar, dp, math, trees
Correct Solution:
```
import sys
inp = [int(x) for x in sys.stdin.read().split()]
n, m, q = inp[0], inp[1], inp[2]
p = [inp[idx] for idx in range(3, n + 3)]
index_arr = [0] * (n + 1)
for i in range(n): index_arr[p[i]] = i
a = [inp[idx] for idx in range(n ... | output | 1 | 96,999 | 12 | 193,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd be... | instruction | 0 | 97,000 | 12 | 194,000 |
No | output | 1 | 97,000 | 12 | 194,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd be... | instruction | 0 | 97,001 | 12 | 194,002 |
No | output | 1 | 97,001 | 12 | 194,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd be... | instruction | 0 | 97,002 | 12 | 194,004 |
No | output | 1 | 97,002 | 12 | 194,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd be... | instruction | 0 | 97,003 | 12 | 194,006 |
No | output | 1 | 97,003 | 12 | 194,007 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,068 | 12 | 194,136 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
import sys
n = sys.stdin.readline()
n = int(n)
def get_graph(n):
graph = []
for _ in range(n):
entries = list(map(lambda x : int(x), sys.stdin.readline().split(" ")[1:]))
graph.append(entries)
return graph
def chain(target, ... | output | 1 | 97,068 | 12 | 194,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,069 | 12 | 194,138 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
from collections import defaultdict
data = defaultdict(list)
position = defaultdict()
nxt = defaultdict()
agg_sum = list()
k = int(input())
trace = defaultdict()
F = [False for x in range(1 << k)]
back = [0 for x in range(1 << k)]
total_sum = 0
res = [... | output | 1 | 97,069 | 12 | 194,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,070 | 12 | 194,140 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
def main():
k = int(input())
n = []
a = []
for i in range(k):
line = [int(x) for x in input().split()]
ni = line[0]
ai = []
n.append(ni)
a.append(ai)
for j in range(ni):
ai.appe... | output | 1 | 97,070 | 12 | 194,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,071 | 12 | 194,142 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
def main():
k = int(input())
n = []
a = []
for i in range(k):
line = [int(x) for x in input().split()]
ni = line[0]
ai = []
n.append(ni)
a.append(ai)
for j in range(ni):
ai.appe... | output | 1 | 97,071 | 12 | 194,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,072 | 12 | 194,144 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
k = int(input())
d = {}
aa = []
sa = []
for i in range(k):
ni, *a = map(int, input().split())
for ai in a:
d[ai] = i
aa.append(a)
sa.append(sum(a))
s = ... | output | 1 | 97,072 | 12 | 194,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,073 | 12 | 194,146 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
from itertools import accumulate
from sys import stdin, stdout
def main():
k = int(stdin.readline())
a = [
tuple(map(int, stdin.readline().split()[1:]))
for _ in range(k)
]
a2ij = {
aij: (i, j)
for i, ai ... | output | 1 | 97,073 | 12 | 194,147 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,074 | 12 | 194,148 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
from itertools import accumulate
from sys import stdin, stdout
def main():
k = int(stdin.readline())
a = [
tuple(map(int, stdin.readline().split()[1:]))
for _ in range(k)
]
a2ij = {
aij: (i, j)
for i, ai ... | output | 1 | 97,074 | 12 | 194,149 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers a... | instruction | 0 | 97,075 | 12 | 194,150 |
Tags: bitmasks, dfs and similar, dp, graphs
Correct Solution:
```
import sys
n = sys.stdin.readline()
n = int(n)
def get_graph(n):
graph = []
for _ in range(n):
entries = list(map(lambda x : int(x), sys.stdin.readline().split(" ")[1:]))
graph.append(entries)
return graph
def chain(target, ... | output | 1 | 97,075 | 12 | 194,151 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.