From 4ed6ffcd3c02415849340c979d46d58f7581bb22 Mon Sep 17 00:00:00 2001 From: s1amx Date: Sat, 6 Feb 2021 11:14:58 +0300 Subject: [PATCH 01/14] Update README.md --- README.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index fc90160..fb9b296 100644 --- a/README.md +++ b/README.md @@ -1,10 +1 @@ - -```shell -pip install pipenv -``` - -``` -pipenv shell -``` - -После установки pipenv в левом нижнем углу при использовании `vscode` следует выбрать версию интерпретатора, привязанную к проекту \ No newline at end of file +Maksim Silin \ No newline at end of file From eb5d870f12b1f3d1992882420683b49ca0d856e0 Mon Sep 17 00:00:00 2001 From: s1amx Date: Sat, 6 Feb 2021 11:19:15 +0300 Subject: [PATCH 02/14] Update main.py --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 6d95fe9..97b2c36 100644 --- a/src/main.py +++ b/src/main.py @@ -1 +1 @@ -print("Hello world") \ No newline at end of file +print("Maksim Silin") \ No newline at end of file From d551b1e31c3cb557766bc4b2354952174751d11b Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Fri, 12 Feb 2021 22:10:54 +0300 Subject: [PATCH 03/14] taks --- src/task1.py | 2 ++ src/task2.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 src/task1.py create mode 100644 src/task2.py diff --git a/src/task1.py b/src/task1.py new file mode 100644 index 0000000..a0852a7 --- /dev/null +++ b/src/task1.py @@ -0,0 +1,2 @@ +A,B = [int(i) for i in input().split(" ")] +print(A+B) diff --git a/src/task2.py b/src/task2.py new file mode 100644 index 0000000..f7e98af --- /dev/null +++ b/src/task2.py @@ -0,0 +1,2 @@ +a, b = input().split(' ') +print(int(a)+int(b)) \ No newline at end of file From ee17d32af21dcf5c7c4ae9abb6fc22132dbc7338 Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Fri, 12 Feb 2021 22:41:44 +0300 Subject: [PATCH 04/14] update task2 --- src/task2.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/task2.py b/src/task2.py index f7e98af..3d46fea 100644 --- a/src/task2.py +++ b/src/task2.py @@ -1,2 +1 @@ -a, b = input().split(' ') -print(int(a)+int(b)) \ No newline at end of file +print("Hello, "+input()+'!') \ No newline at end of file From 2fc423e0c058e85e5562a86f1a556c0c23e2f113 Mon Sep 17 00:00:00 2001 From: s1amx Date: Sat, 6 Mar 2021 10:09:23 +0300 Subject: [PATCH 05/14] bubble_sort --- src/bubble_sort.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/bubble_sort.py diff --git a/src/bubble_sort.py b/src/bubble_sort.py new file mode 100644 index 0000000..5abb123 --- /dev/null +++ b/src/bubble_sort.py @@ -0,0 +1,15 @@ +N=int(input(" ")) +a= [int(i)for i in input().split(" ")] +num_swap=0 +for i in range(N-1): + for j in range(N-1-i): + if a[j+1] Date: Sat, 6 Mar 2021 10:12:45 +0300 Subject: [PATCH 06/14] bubble_sort2 --- src/bubble_sort2.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/bubble_sort2.py diff --git a/src/bubble_sort2.py b/src/bubble_sort2.py new file mode 100644 index 0000000..1d0896a --- /dev/null +++ b/src/bubble_sort2.py @@ -0,0 +1,17 @@ +n= int(input()) +s=[] +for i in range (n): + s.append(input().split(" ")) +s=[[int(s[i][j]) for j in range(2)] for i in range(n)] +for i in range(n-1): + for j in range (n-1-i): + if s[j][1]s[j+1][0]: + t = s[j+1] + s[j+1] = s[j] + s[j] = t + +[print(i[0], i[1]) for i in s] \ No newline at end of file From 08b65e1a77d640fe36837e64c5a1bd5705a97dfe Mon Sep 17 00:00:00 2001 From: s1amx Date: Sat, 6 Mar 2021 10:15:58 +0300 Subject: [PATCH 07/14] task5 --- src/task5.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/task5.py diff --git a/src/task5.py b/src/task5.py new file mode 100644 index 0000000..d005d38 --- /dev/null +++ b/src/task5.py @@ -0,0 +1,8 @@ +c = 1 +n = int(input()) +numbers = list(map(int, input().split(maxsplit = n))) +numbers.sort() +for i in range(1, n): + if numbers[i-1] != numbers[i]: + c= c+1 +print(c) \ No newline at end of file From aede9a528a3b55cb47438ad77345f4d5f9437594 Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Sat, 6 Mar 2021 13:45:08 +0300 Subject: [PATCH 08/14] task6 sklad --- src/task6_sklad.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/task6_sklad.py diff --git a/src/task6_sklad.py b/src/task6_sklad.py new file mode 100644 index 0000000..1d731dd --- /dev/null +++ b/src/task6_sklad.py @@ -0,0 +1,14 @@ +Q = int(input()) +H = list(map(int, input().split(" "))) +s = int(input()) +X = list(map(int, input().split(" "))) +def m(a, b, n): + mass = [0]*(n+1) + for j in b: + mass[j] = mass[j]+1 + for i in range(n): + if a[i] >= mass[i+1]: + print("no") + else: + print("yes") +m(H, X, Q) \ No newline at end of file From 75879df57ccdf321205e24eb2af91d04e633b5c3 Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Sun, 14 Mar 2021 16:27:12 +0300 Subject: [PATCH 09/14] task7 Maksim Silin --- src/tasknum7.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/tasknum7.py diff --git a/src/tasknum7.py b/src/tasknum7.py new file mode 100644 index 0000000..aba74a5 --- /dev/null +++ b/src/tasknum7.py @@ -0,0 +1,26 @@ +def taskseven(C, x): + digit = len(C[0]) + for i in range(digit): + mass = [[] for j in range(10)] + for item in C: + index = int(item)//10**i % 10 + mass[index].append(item) + print("Phase", i+1) + C = [] + for i in range(10): + print("Bucket ", i ,":", sep = "", end=" ") + print(", ".join(mass[i]) if len(mass[i])>0 else "empty") + C += mass[i] + print("**********") + return C + +x = int(input()) +C = [] +for i in range(x): + C.append(input()) +print("Initial array:") +print(", ".join(C)) +print("**********") +C = taskseven(C, x) +print("Sorted array:") +print(", ".join(C)) \ No newline at end of file From 401cba440e1efe10a463a8e9f9e5556d9372cb3a Mon Sep 17 00:00:00 2001 From: s1amx Date: Sat, 20 Mar 2021 10:16:01 +0300 Subject: [PATCH 10/14] tasknum3 Maksim Silin --- src/tasknum3.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/tasknum3.py diff --git a/src/tasknum3.py b/src/tasknum3.py new file mode 100644 index 0000000..09dc409 --- /dev/null +++ b/src/tasknum3.py @@ -0,0 +1,35 @@ +def merge_sort(num, start,end): + if (end - start > 1): + mid = (start + end) // 2 + merge_sort(num, start, mid) + merge_sort(num, mid, end) + left = num [start: mid] + right = num[mid: end] + internal_sort(num, left, right, start) + print(start +1, end, num[start], num[end - 1]) +def internal_sort(mass, left, right, start): + i = j = 0 # i -> right j -> left + k = start + while i < len(right) and j < len(left): + if left[j] > right[i]: + mass[k] = right[i] + i = i+1 + else: + mass[k] = left[j] + j =j+1 + k =k+1 + while j < len(left): + mass [k] = left[j] + j=j+1 + k=k+1 + while i < len(right): + mass[k] = right[i] + i=i+1 + k=k+1 +def main(): + n = int(input()) + num = list(map(int, input().split(maxsplit = n))) + merge_sort(num, 0, len(num)) + print(*num) + +main() \ No newline at end of file From 43be0d1659e824ef4366b7ad2e0f12955fb004f0 Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Sun, 18 Apr 2021 15:42:34 +0300 Subject: [PATCH 11/14] mod3_task1,4 Maksim Silin --- src/mod3_task1.py | 22 ++++++++++++++++++++++ src/mod3_task4.py | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/mod3_task1.py create mode 100644 src/mod3_task4.py diff --git a/src/mod3_task1.py b/src/mod3_task1.py new file mode 100644 index 0000000..b8b1641 --- /dev/null +++ b/src/mod3_task1.py @@ -0,0 +1,22 @@ +def func(c): + mass=[0]*len(c) + m = a =0 + for i in range(1, len(c)): + if i <= a: + mass[i] = min(mass[i-m], a-i+1) + while mass[i] + i < len(c) and c[mass[i]] == c[mass[i]+i]: + mass[i]= mass[i]+1 + if mass [i] + i - 1 > a: + m=i + a = mass[i] + i - 1 + return mass + +def main(): + c = input() + t = input() + s = func(t+"#" + c) + for i in range(len(s)): + if len(t) == s[i]: + print(i- len(t) - 1, end = " ") + +main() \ No newline at end of file diff --git a/src/mod3_task4.py b/src/mod3_task4.py new file mode 100644 index 0000000..98cf988 --- /dev/null +++ b/src/mod3_task4.py @@ -0,0 +1,18 @@ +def function(c): + x = len(c) + count = [0] * x + count[0] = 0 + for i in range (x - 1): + j = count[i] + while (j > 0) and (c[i + 1] != c[j]): + j = count[j - 1] + if (c[i + 1] == c[j]): + count[i+1] = j + 1 + else: + count[i + 1] = 0 + return count +txt = str(input()) +c = list(txt) +x = len(c) +pref = function(c) +print(x - pref[-1]) \ No newline at end of file From d6f747598b06b7b25a58975639ebc27c58767248 Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Wed, 26 May 2021 11:57:35 +0300 Subject: [PATCH 12/14] mod3_task2/3 --- src/mod3_task2.py | 36 ++++++++++++++++++++++++++++++++++++ src/mod3_task3.py | 23 +++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/mod3_task2.py create mode 100644 src/mod3_task3.py diff --git a/src/mod3_task2.py b/src/mod3_task2.py new file mode 100644 index 0000000..7b3a957 --- /dev/null +++ b/src/mod3_task2.py @@ -0,0 +1,36 @@ +def cyclic_shift(a,b,c): + hash = 0 + for i in range(len(a)): + hash = (hash*b+ord(a[i]))%c + return hash + +def function(a,t,b,c): + if a!=t: + mass = 1 + t = t[1:] + t[0] + c_s = cyclic_shift(a,b,c) + t_s = cyclic_shift(t,b,c) + k = 1 + for i in range(len(a)-1): + k=(k*b)%c + for i in range(len(t)-1): + if c_s == t_s: + break + else: + t_s = (b*(t_s-ord(t[i])*k) + ord(t[i]))%c + mass= mass+1 + if c_s == t_s: + print(mass) + else: + print(-1) + else: + print(0) + +def main(): + a = input() + t = input() + b = 30 + c = 1e9+6 + a = function(a,t,b,c) + +main() diff --git a/src/mod3_task3.py b/src/mod3_task3.py new file mode 100644 index 0000000..91de194 --- /dev/null +++ b/src/mod3_task3.py @@ -0,0 +1,23 @@ +def period(c): + a = [0] * len(c) + for i in range(1, len(c)): + z = a[i-1] + while (z > 0 and c[z] != c[i]): + z = a[z - 1] + if c[i] == c[z]: + z= z+1 + a[i] = z + return a + +def main(): + c = input() + c_t = c + '&' + c + L = period(c_t) + lr = L[-1]-L[len(c)-1] + z = len(c)//lr + if c[:lr]*z == c: + print(z) + else: + print(1) + +main() \ No newline at end of file From 0d40ad40a24eb906ae71bb3f3952b6c76241d700 Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Wed, 26 May 2021 12:18:09 +0300 Subject: [PATCH 13/14] mod4_task1 --- src/{task1.py => mod1_task1.py} | 0 src/{task2.py => mod1_task2.py} | 0 src/mod2_task1.py | 15 +++++++++++++++ src/mod2_task2.py | 17 +++++++++++++++++ src/{tasknum3.py => mod2_task3.py} | 0 src/{task5.py => mod2_task5.py} | 0 src/{task6_sklad.py => mod2_task6.py} | 0 src/{tasknum7.py => mod2_task7.py} | 0 src/mod4_task1.py | 14 ++++++++++++++ 9 files changed, 46 insertions(+) rename src/{task1.py => mod1_task1.py} (100%) rename src/{task2.py => mod1_task2.py} (100%) create mode 100644 src/mod2_task1.py create mode 100644 src/mod2_task2.py rename src/{tasknum3.py => mod2_task3.py} (100%) rename src/{task5.py => mod2_task5.py} (100%) rename src/{task6_sklad.py => mod2_task6.py} (100%) rename src/{tasknum7.py => mod2_task7.py} (100%) create mode 100644 src/mod4_task1.py diff --git a/src/task1.py b/src/mod1_task1.py similarity index 100% rename from src/task1.py rename to src/mod1_task1.py diff --git a/src/task2.py b/src/mod1_task2.py similarity index 100% rename from src/task2.py rename to src/mod1_task2.py diff --git a/src/mod2_task1.py b/src/mod2_task1.py new file mode 100644 index 0000000..5abb123 --- /dev/null +++ b/src/mod2_task1.py @@ -0,0 +1,15 @@ +N=int(input(" ")) +a= [int(i)for i in input().split(" ")] +num_swap=0 +for i in range(N-1): + for j in range(N-1-i): + if a[j+1]s[j+1][0]: + t = s[j+1] + s[j+1] = s[j] + s[j] = t + +[print(i[0], i[1]) for i in s] \ No newline at end of file diff --git a/src/tasknum3.py b/src/mod2_task3.py similarity index 100% rename from src/tasknum3.py rename to src/mod2_task3.py diff --git a/src/task5.py b/src/mod2_task5.py similarity index 100% rename from src/task5.py rename to src/mod2_task5.py diff --git a/src/task6_sklad.py b/src/mod2_task6.py similarity index 100% rename from src/task6_sklad.py rename to src/mod2_task6.py diff --git a/src/tasknum7.py b/src/mod2_task7.py similarity index 100% rename from src/tasknum7.py rename to src/mod2_task7.py diff --git a/src/mod4_task1.py b/src/mod4_task1.py new file mode 100644 index 0000000..9f03e8e --- /dev/null +++ b/src/mod4_task1.py @@ -0,0 +1,14 @@ +def psp(c): + Counter = 0 + mass = [] + for i in c: + if (i == '('): + mass.append(i) + elif (mass != []) and (mass[-1] == '('): + mass.pop() + else: + Counter= Counter+1 + return Counter+len(mass) + +c = str(input()) +print(psp(c)) \ No newline at end of file From ad8a45391c18f1d3bba42c29e92428fe61ce8cec Mon Sep 17 00:00:00 2001 From: s1max <72213224+s1max@users.noreply.github.com> Date: Wed, 2 Jun 2021 14:13:20 +0300 Subject: [PATCH 14/14] mod4_task2,3,4 --- src/mod4_task2.py | 23 +++++++++++++++++++++++ src/mod4_task3.py | 23 +++++++++++++++++++++++ src/mod4_task4.py | 17 +++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/mod4_task2.py create mode 100644 src/mod4_task3.py create mode 100644 src/mod4_task4.py diff --git a/src/mod4_task2.py b/src/mod4_task2.py new file mode 100644 index 0000000..525991c --- /dev/null +++ b/src/mod4_task2.py @@ -0,0 +1,23 @@ +p = int(input()) +c = list(map(int, input().split())) + +impasse = [0] +wayB = [0] + +for i in range(p): + while impasse[-1] == wayB[-1] + 1: + wayB.append(impasse[-1]) + impasse.pop() + if c[i] == wayB[-1] + 1: + wayB.append(c[i]) + else: + impasse.append(c[i]) + +while impasse[-1] == wayB[-1] + 1: + wayB.append(impasse[-1]) + impasse.pop() + +if wayB[-1] == p: + print('YES') +else: + print('NO') \ No newline at end of file diff --git a/src/mod4_task3.py b/src/mod4_task3.py new file mode 100644 index 0000000..4d7201e --- /dev/null +++ b/src/mod4_task3.py @@ -0,0 +1,23 @@ +def close(C, p): + stk = [p-1] + index = [0]*p + index[p-1] = -1 + for i in range(p-2, -1, -1): + if C[stk[-1]] >= C[i]: + while (stk != []) and (C[stk[-1]] >= C[i]): + stk.pop() + if (stk == []): + index[i] = -1 + else: + index[i] = stk[-1] + stk.append(i) + else: + index[i] = stk[-1] + stk.append(i) + return index + + +N = int(input()) +C = list(map(int, input().split())) +C = close(C, N) +print(' '.join(map(str, C))) \ No newline at end of file diff --git a/src/mod4_task4.py b/src/mod4_task4.py new file mode 100644 index 0000000..3caabc8 --- /dev/null +++ b/src/mod4_task4.py @@ -0,0 +1,17 @@ +def min_segment(p, m_w, c): + mass = [] + for i in range(m_w): + while mass and c[i] <= c[mass[-1]]: + mass.pop() + mass.append(i) + for i in range(m_w, p): + print(c[mass[0]]) + while mass and i - m_w >= mass[0]: + mass.pop(0) + while mass and c[i] <= c[mass[-1]]: + mass.pop() + mass.append(i) + print(c[mass[0]]) +N, K = map(int, input().split()) +c = list(map(int, input().split())) +min_segment(N, K, c) \ No newline at end of file