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 |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular n Γ m matrix a. In one move you can choose any column and cyclically shift elem... | instruction | 0 | 22,941 | 12 | 45,882 |
No | output | 1 | 22,941 | 12 | 45,883 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular n Γ m matrix a. In one move you can choose any column and cyclically shift elem... | instruction | 0 | 22,942 | 12 | 45,884 |
No | output | 1 | 22,942 | 12 | 45,885 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular n Γ m matrix a. In one move you can choose any column and cyclically shift elem... | instruction | 0 | 22,943 | 12 | 45,886 |
No | output | 1 | 22,943 | 12 | 45,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,960 | 12 | 45,920 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
n, k = list(map(int, input().strip().split()))
x = []
for i in range(1, k + 2):
print("? " + ' '.join([str(x) for x in range(1, k + 2) if x != i]))
a, b = list(map(int, input().strip().split()))
x.append(b)
z = 0
xx = max(x)
fo... | output | 1 | 22,960 | 12 | 45,921 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,961 | 12 | 45,922 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
import sys
def query(a):
print('?', *a)
sys.stdout.flush()
p, v = map(int, input().split())
return p, v
n, k = map(int, input().split())
a = list(range(1, k+1))
stack = []
for i in range(1, k+1):
_, v = query(a)
... | output | 1 | 22,961 | 12 | 45,923 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,962 | 12 | 45,924 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
from sys import stdout
from collections import defaultdict
d = defaultdict(int)
n, k = map(int, input().split())
for i in range(1, k+2):
array = ['?']
for j in range(1, k+2):
if j != i:
array.append(j)
print... | output | 1 | 22,962 | 12 | 45,925 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,963 | 12 | 45,926 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
from sys import stdout
from collections import defaultdict
def make_query(l):
s = ["?"]
for i in l:
s.append(str(i))
print(" ".join(s))
stdout.flush()
idx,element = map(int, input().split())
return idx,... | output | 1 | 22,963 | 12 | 45,927 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,964 | 12 | 45,928 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
import sys
def solution():
n, k = [int(i) for i in input().strip().split()]
foo = '? ' + ' '.join([str(i + 1) for i in range(k)]) + ' '
bar = ' ' + str(k + 1) + ' '
sys.stdout.write(foo.strip() + '\n')
sys.stdout.flush... | output | 1 | 22,964 | 12 | 45,929 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,965 | 12 | 45,930 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
import sys
def print(s = "", end = "\n"):
sys.stdout.write(str(s)+end)
def input():
return sys.stdin.readline().rstrip()
n, k = map(int,input().split())
ans = []
for i in range(k + 1):
print("?", end = " ")
for j in range(k... | output | 1 | 22,965 | 12 | 45,931 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,966 | 12 | 45,932 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
from sys import stdout
n, k = map(int, input().split())
n1, n2 = 0, 0
e1, e2 = -1, -1
elems = [i + 1 for i in range(k + 1)]
for i in range(k + 1):
print('?', *elems[:i], *elems[i + 1:k + 1])
stdout.flush()
pos, elem = map(int,... | output | 1 | 22,966 | 12 | 45,933 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device ca... | instruction | 0 | 22,967 | 12 | 45,934 |
Tags: constructive algorithms, interactive, math, sortings
Correct Solution:
```
from sys import stdout
n,k = list(map(int,input().split()))
value1,value2 = -1,-1
count1,count2=0,0
for i in range(1,k+2):
query = ["?"]
for j in range(1,k+2):
if i!=j:
query.append(j)
print(*query)
s... | output | 1 | 22,967 | 12 | 45,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,008 | 12 | 46,016 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
# cook your dish here
from sys import stdin
import sys
if __name__=="__main__":
for _ in range (int(stdin.readline())):
n=int(stdin.readline())
arr=list(map(int,stdin.readline().split()))
dp=[[0]*(n+1) for i in range... | output | 1 | 23,008 | 12 | 46,017 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,009 | 12 | 46,018 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
# import bisect
# import os
# import io
# from collections import Counter
import bisect
from collections import defaultdict
# import math
# import random
# import heapq as hq
# from math import sqrt
import sys
from functools import reduce, cmp_t... | output | 1 | 23,009 | 12 | 46,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,010 | 12 | 46,020 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
from collections import defaultdict
def solve():
n = int(input())
a = list(map(int, input().split()))
V = max(a)
#a[i]<=200
ans = 0
cnt = [[0]*(n+1) for i in range(V+1)]
for i, v in enumerate(a):
cnt[v][i+1] ... | output | 1 | 23,010 | 12 | 46,021 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,011 | 12 | 46,022 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
import sys
input=sys.stdin.readline
t=int(input())
for i in range(t):
n=int(input())
a=[int(i)-1 for i in input().split()]
dp=[[0 for _ in range(200)] for _ in range(n)]
for i in range(n):
for j in range(200):
dp[i][j]... | output | 1 | 23,011 | 12 | 46,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,012 | 12 | 46,024 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
#import io, os
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
input=sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int,input()))
f = lambda: ma... | output | 1 | 23,012 | 12 | 46,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,013 | 12 | 46,026 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
import sys
import collections
import threading
import string
def sparsetable(a):
tmp = [0]*201
st = []
for i in range(len(a)):
tmp[a[i]] += 1
st.append(tmp[:])
return st
def func(x, y, st):
if x>=y: return 0... | output | 1 | 23,013 | 12 | 46,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,014 | 12 | 46,028 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
#!/usr/bin/env python
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.writa... | output | 1 | 23,014 | 12 | 46,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these... | instruction | 0 | 23,015 | 12 | 46,030 |
Tags: brute force, data structures, dp, two pointers
Correct Solution:
```
# this problem is solved with the help of tutorial.
def sm(c,l,r):
return occur[c][r+1]-occur[c][l]
t=int(input())
for z in range(t):
n=int(input())
arr=list(map(int,input().split()))
brr=list(set(arr))
pos=[[] for i in ran... | output | 1 | 23,015 | 12 | 46,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,016 | 12 | 46,032 |
Yes | output | 1 | 23,016 | 12 | 46,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,017 | 12 | 46,034 |
Yes | output | 1 | 23,017 | 12 | 46,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,018 | 12 | 46,036 |
Yes | output | 1 | 23,018 | 12 | 46,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,019 | 12 | 46,038 |
Yes | output | 1 | 23,019 | 12 | 46,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,020 | 12 | 46,040 |
No | output | 1 | 23,020 | 12 | 46,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,021 | 12 | 46,042 |
No | output | 1 | 23,021 | 12 | 46,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,022 | 12 | 46,044 |
No | output | 1 | 23,022 | 12 | 46,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consist... | instruction | 0 | 23,023 | 12 | 46,046 |
No | output | 1 | 23,023 | 12 | 46,047 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura owns a quite ordinary and boring array a of length n. You think there is nothing more boring than that, but Vladik doesn't agree!
In order to make Yura's array even more boring, Vladik mak... | instruction | 0 | 23,073 | 12 | 46,146 |
No | output | 1 | 23,073 | 12 | 46,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura owns a quite ordinary and boring array a of length n. You think there is nothing more boring than that, but Vladik doesn't agree!
In order to make Yura's array even more boring, Vladik mak... | instruction | 0 | 23,074 | 12 | 46,148 |
No | output | 1 | 23,074 | 12 | 46,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura owns a quite ordinary and boring array a of length n. You think there is nothing more boring than that, but Vladik doesn't agree!
In order to make Yura's array even more boring, Vladik mak... | instruction | 0 | 23,075 | 12 | 46,150 |
No | output | 1 | 23,075 | 12 | 46,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura owns a quite ordinary and boring array a of length n. You think there is nothing more boring than that, but Vladik doesn't agree!
In order to make Yura's array even more boring, Vladik mak... | instruction | 0 | 23,076 | 12 | 46,152 |
No | output | 1 | 23,076 | 12 | 46,153 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,083 | 12 | 46,166 |
Tags: data structures, dp, greedy
Correct Solution:
```
import sys
input = sys.stdin.readline
def ri(): return [int(i) for i in input().split()]
# Fenwick max
def ft_max_set(t, at, val):
while at < len(t):
t[at] = max(t[at], val)
at |= at + 1
def ft_max_query(t, at):
res = 0
while at ... | output | 1 | 23,083 | 12 | 46,167 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,084 | 12 | 46,168 |
Tags: data structures, dp, greedy
Correct Solution:
```
import bisect as bs
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if n <= 2:
print(n)
continue
stack, m, p = [a[0]], [], [(1000000, 0)]
for v in a[1:]:
k = bs.bisect_right(m, v)
... | output | 1 | 23,084 | 12 | 46,169 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,085 | 12 | 46,170 |
Tags: data structures, dp, greedy
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
def __init__(self, file):
self.newlines = 0
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mo... | output | 1 | 23,085 | 12 | 46,171 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,086 | 12 | 46,172 |
Tags: data structures, dp, greedy
Correct Solution:
```
import bisect as bs
for _ in range(int(input())):
n, a = int(input()), list(map(int, input().split()))
stack, m, p = [a[0]], [], [(1000000, 0)]
for v in a[1:]:
k = bs.bisect_right(m, v)
if k == len(m):
stack.append(v)
... | output | 1 | 23,086 | 12 | 46,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,087 | 12 | 46,174 |
Tags: data structures, dp, greedy
Correct Solution:
```
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998... | output | 1 | 23,087 | 12 | 46,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,088 | 12 | 46,176 |
Tags: data structures, dp, greedy
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
def __init__(self, file):
self.newlines = 0
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mo... | output | 1 | 23,088 | 12 | 46,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a s... | instruction | 0 | 23,089 | 12 | 46,178 |
Tags: data structures, dp, greedy
Correct Solution:
```
import bisect as bs
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if n <= 2:
print(n)
continue
stack, m, p = [a[0]], [], [(1000000, 0)]
for v in a[1:]:
k = bs.bisect_right(m, v)
... | output | 1 | 23,089 | 12 | 46,179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two el... | instruction | 0 | 23,090 | 12 | 46,180 |
No | output | 1 | 23,090 | 12 | 46,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two el... | instruction | 0 | 23,091 | 12 | 46,182 |
No | output | 1 | 23,091 | 12 | 46,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two el... | instruction | 0 | 23,092 | 12 | 46,184 |
No | output | 1 | 23,092 | 12 | 46,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) β€ min(b_2, b_3) β€ ... β€ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two el... | instruction | 0 | 23,093 | 12 | 46,186 |
No | output | 1 | 23,093 | 12 | 46,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,166 | 12 | 46,332 |
Tags: constructive algorithms, math
Correct Solution:
```
n = int(input())
if n%4 > 1:
print(-1)
else:
a = [n+1>>1]*n
for i in range(n//4):
j = i*2
a[j], a[j+1], a[-2-j], a[-1-j] = j+2, n-j, j+1, n-1-j
print(' '.join(map(str, a)))
``` | output | 1 | 23,166 | 12 | 46,333 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,167 | 12 | 46,334 |
Tags: constructive algorithms, math
Correct Solution:
```
'''
Created on
@author: linhz
'''
import sys
usedNum=0
n=int(input())
p=[0 for i in range(n+1)]
usedNum=0
if n%4==3 or n%4==2:
print(-1)
else:
i=1
j=n
a=1
b=n
while j>i:
p[i]=a+1
p[i+1]=b
p[j]=b-1
p[j-1]=a... | output | 1 | 23,167 | 12 | 46,335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,168 | 12 | 46,336 |
Tags: constructive algorithms, math
Correct Solution:
```
from itertools import permutations
from sys import stdin
def checkit(vector, upto=-1):
if upto == -1:
upto = len(vector)
for i in range(0, upto):
if vector[vector[i] - 1] != len(vector) - (i + 1) + 1:
return False
return... | output | 1 | 23,168 | 12 | 46,337 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,169 | 12 | 46,338 |
Tags: constructive algorithms, math
Correct Solution:
```
import sys
from collections import deque
n = int(input())
if n % 4 == 2 or n % 4 == 3:
print('-1')
sys.exit()
arr = [None] * (n + 1)
qt = deque([i for i in range(1, n + 1)])
mark = set()
while qt:
while qt and qt[0] in mark:
qt.popleft()
... | output | 1 | 23,169 | 12 | 46,339 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,170 | 12 | 46,340 |
Tags: constructive algorithms, math
Correct Solution:
```
n=int(input())
if n%4>1:print(-1)
else:
ans=[i for i in range(1,n+1)]
for i in range(0,n//2,2):
ans[i]=i+2
ans[i+1]=n-i
ans[n-i-1]=n-i-1
ans[n-i-2]=i+1
print(*ans)
``` | output | 1 | 23,170 | 12 | 46,341 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,171 | 12 | 46,342 |
Tags: constructive algorithms, math
Correct Solution:
```
n = int(input())
if n%4==2 or n%4==3:
print(-1)
else:
ans = [0]*n
for i in range(0, n//2, 2):
ans[i] = i+2
ans[i+1] = n-i
ans[n-i-1] = n-i-1
ans[n-i-2] = i+1
if n%4 == 1:
ans[n//2] = n//2 + 1
print(*ans)
``` | output | 1 | 23,171 | 12 | 46,343 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,172 | 12 | 46,344 |
Tags: constructive algorithms, math
Correct Solution:
```
n = int(input())
if n % 4 > 1: print(-1)
else:
k = n // 2
t = [0] * n
for i in range(0, k, 2):
t[i] = str(i + 2)
for i in range(1, k, 2):
t[i] = str(n - i + 1)
if n & 1:
k += 1
t[k - 1] = str(k)
for i in ra... | output | 1 | 23,172 | 12 | 46,345 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 β€ pi β€ n).
A lucky permutation is such permutation p, that any integer i (1 β€ i β€ n) meets this condition ppi = n -... | instruction | 0 | 23,173 | 12 | 46,346 |
Tags: constructive algorithms, math
Correct Solution:
```
n=int(input())
if n==1:
print (1)
exit()
if n%4>1:
print (-1)
exit()
ans=[-1]*n
left=n
start=n-2
nums=1
nume=n
while left>=4:
ans[start]=nums
ans[nums-1]=nums+1
ans[nums]=nume
ans[nume-1]=nume-1
start-=2
nums+=2
nume-=2
left-=4
# print (ans)
if left... | output | 1 | 23,173 | 12 | 46,347 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.