diff --git a/uts/session_py/1.py b/uts/session_py/1.py new file mode 100644 index 0000000..4d7dcfb --- /dev/null +++ b/uts/session_py/1.py @@ -0,0 +1,41 @@ +from random import randint +#x=int(input()) +#y=int(input()) +x=10 +y=10 +sum=0; +maxoffset = 0; +cordx=0; +cordy=0; +mini = min(x,y) +mass = [[randint(0,1) for i in range(x)] for o in range(y)] +for i in range(y): + print(mass[i]) +for i in range(y): + for o in range(x): + if mass[i][o] == 0: + sum=0; + ii = 0; + #print("found zero at ",o,i) + for ii in range(mini): + if ii+o >= x: + break + if ii+i >= y: + break + sum = sum + mass[i + ii][o + ii] + for oo in range(ii): + sum = sum + mass[i+ii][o+oo] + sum = sum + mass[i+oo][o+ii] + if sum != 0: + break + #print("end zero at offset", ii) + if (maxoffset< ii): + maxoffset = ii + cordx = o + cordy = i + #print("!write bigger offset") +print(cordx+1, cordy+1, cordx+maxoffset, cordy+maxoffset) +print('these numbers should be zeroes') +for i in range(cordy,cordy+maxoffset): + for o in range(cordx,cordx+maxoffset): + print(mass[i][o]) \ No newline at end of file diff --git a/uts/session_py/10.py b/uts/session_py/10.py new file mode 100644 index 0000000..10c7fd0 --- /dev/null +++ b/uts/session_py/10.py @@ -0,0 +1,13 @@ +from random import * +from math import * + +n = 10000 +k = 0 + +for i in range(n): + x = uniform(-sqrt(2)/3, sqrt(2)/3) + y = uniform(-sqrt(2)/3, sqrt(2)/3) + z = uniform(-sqrt(2)/3, sqrt(2)/3) + if (): + k+=1 +print(k/n) diff --git a/uts/session_py/18.02.17.py b/uts/session_py/18.02.17.py new file mode 100644 index 0000000..9f4b550 --- /dev/null +++ b/uts/session_py/18.02.17.py @@ -0,0 +1,8 @@ +import sys +sys.stdin = open("sta.txt", "r") + +sta, n = list(map(int, input().split())) +s = [] +for i in range(sta): + s.append(input()) +print(s) diff --git a/uts/session_py/2.py b/uts/session_py/2.py new file mode 100644 index 0000000..6f38e24 --- /dev/null +++ b/uts/session_py/2.py @@ -0,0 +1,7 @@ +n=7 +mass = [[1 for i in range(n)]] +current_max = 1; +print(mass) +for i in range(1,n): + current_max = current_max +1; + cur_list = mass[i-1] diff --git a/uts/session_py/3.py b/uts/session_py/3.py new file mode 100644 index 0000000..223ed81 --- /dev/null +++ b/uts/session_py/3.py @@ -0,0 +1,41 @@ +import sys + +problem_name = str('calendar') +sys.stdin = open(problem_name + ".in", "r") +# sys.stdout = open(problem_name+".out", "w") + +def get_mass(num): + arr = [] + n = num + while n > 0: + arr.append(n%10) + n = n//10 + return arr + +def bad_char(start, end, bad): + counterr = 0 + for day in range(start, end): + an = get_mass(day) + for nu in num: + if nu in an: + counterr += 1 + return counterr + + +n, k = map(int, input().split()) +a = list(map(int, input().split())) +num = list(map(int, input().split())) +print(n,' ',k) +counter = 0 +a.sort() +print(a) +lastmas = 0 +lastcount = 0 + +for mounth in a: + if lastmas == mounth: + counter = counter + lastcount + else: + counter = counter + lastcount + lastcount + bad_char(lastmas, mounth, num) + lastmas = mounth +print(counter) \ No newline at end of file diff --git a/uts/session_py/4.py b/uts/session_py/4.py new file mode 100644 index 0000000..c06fc08 --- /dev/null +++ b/uts/session_py/4.py @@ -0,0 +1,10 @@ +import sys +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") +n = int(input()) +count = 0 +for i in range(n): + for j in list(map(int, input().split())): + count = count + j +count = count / 2 +print(int(count)) \ No newline at end of file diff --git a/uts/session_py/5.py b/uts/session_py/5.py new file mode 100644 index 0000000..7add913 --- /dev/null +++ b/uts/session_py/5.py @@ -0,0 +1,9 @@ +import sys +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") +n, m = map(int, input().split()) +n_mas = [0 for i in range(n)] +for i in range(m): + for j in list(map(int, input().split())): + n_mas[j-1] += 1 +print(*n_mas) \ No newline at end of file diff --git a/uts/session_py/6.py b/uts/session_py/6.py new file mode 100644 index 0000000..6b21258 --- /dev/null +++ b/uts/session_py/6.py @@ -0,0 +1,19 @@ +import sys +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") +n, m = map(int, input().split()) +mas = [] +for i in range(n): + mas.append(list(map(int, input().split()))) +ans = [[0 for i in range(m)] for j in range(n)] +for i in range(n): + for j in range(m): + dist = 1000 + for k in range(n): + for l in range(m): + if mas[k][l] == 1: + dist = min(dist, abs(k - i) + abs(l-j)) + ans[i][j] = dist +for i in range(len(ans)): + print(*ans[i]) + #http://127.0.0.1:41017/ \ No newline at end of file diff --git a/uts/session_py/7.py b/uts/session_py/7.py new file mode 100644 index 0000000..c05522b --- /dev/null +++ b/uts/session_py/7.py @@ -0,0 +1,10 @@ +from random import randint + +k = 0 +n = 100000 + +for i in range(n): + h = randint(1,6) + if (h == 2) or (h == 5): + k += 1; +print(k/n) \ No newline at end of file diff --git a/uts/session_py/8.py b/uts/session_py/8.py new file mode 100644 index 0000000..3ff1f54 --- /dev/null +++ b/uts/session_py/8.py @@ -0,0 +1,11 @@ +from random import * + +n = 10000 +k = 0 + +for i in range(n): + y = randint(0, 7) + random() + x = randint(0, 9) + random() + if (y <= 4 * x) and (y <= 10-x) and (y >= 0): + k += 1 +print((k/n)*80) \ No newline at end of file diff --git a/uts/session_py/9.py b/uts/session_py/9.py new file mode 100644 index 0000000..7bd3a7d --- /dev/null +++ b/uts/session_py/9.py @@ -0,0 +1,13 @@ +from random import * + +from math import cos, pi + +n = 10000 +k = 0 +for i in range(n): + y = uniform(-1, 1) + x = uniform(-pi, pi) + if ((y <= cos(x)) and (x >= -pi) and (x <= pi) and (y >= 0)) \ + or ((y >= cos(x)) and (x >= -pi) and (x <= pi) and (y <= 0)): + k += 1 +print(k/n*pi*4) \ No newline at end of file diff --git a/uts/session_py/B.py b/uts/session_py/B.py new file mode 100644 index 0000000..05e71ee --- /dev/null +++ b/uts/session_py/B.py @@ -0,0 +1,26 @@ +import sys + +problem_name = str('input') +sys.stdin = open(problem_name + ".txt", "r") +sys.stdout = open("output.txt", "w") + +n, m = map(int, input().split()) +n_mas = list(map(int, input().split())) +m_mas = list(map(int, input().split())) +s = [] +for i in n_mas: + if not (i in m_mas): + s.append(i) +for i in m_mas: + if not (i in n_mas): + s.append(i) +if s == []: + print('EQUAL') +else: + s.sort() + for i in s: + if i in n_mas: + print('+'+str(i)) + else: + print('-'+str(i)) +#vlaDDisLaVuYtk \ No newline at end of file diff --git a/uts/session_py/C.py b/uts/session_py/C.py new file mode 100644 index 0000000..9e108fe --- /dev/null +++ b/uts/session_py/C.py @@ -0,0 +1,10 @@ +w, h, xo, yo, x, y = map(int, input().split()) + +l = abs(x-xo)+abs(y-yo) +ll = yo + abs(h-y) + abs(x-xo) +lll = h-yo+y+abs(x-xo) +llll = xo+abs(w-x)+abs(y-yo) +lllll = w-xo+x+abs(y-yo) +llllll = xo+yo+abs(h-y)+abs(w-x) +lllllll = abs(h-yo)+abs(w-xo)+x+y +print(min(l,ll,lll,llll,lllll,llllll,lllllll)) diff --git a/uts/session_py/Check.py b/uts/session_py/Check.py new file mode 100644 index 0000000..04e9c4b --- /dev/null +++ b/uts/session_py/Check.py @@ -0,0 +1,18 @@ +import sys +sys.stdin = open("input.txt", "r") +#sys.stdout = open("output.txt", "w") + +def dfs(graph, start): + visited, stack = set(), [start] + while stack: + vertex = stack.pop() + if vertex not in visited: + visited.add(vertex) + stack.extend(graph[vertex] - visited) + return visited + +n = int(input()) +mas = [list(map(int, input().split())) for i in range(n)] +visit = [] + +print(mas) \ No newline at end of file diff --git a/uts/session_py/E.py b/uts/session_py/E.py new file mode 100644 index 0000000..2eb784d --- /dev/null +++ b/uts/session_py/E.py @@ -0,0 +1,35 @@ +import sys +problem_name = str('input') +sys.stdout = open("output.txt", "w") +def unff(number, arr, base): + res = "" + while number > 0: + y = arr[number % base] + res = y + res + number = int(number // base) + return res +dec_mas = [] +arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'] +f = open(problem_name + ".txt") +s = [] +for line in f: + s.append(line) +for od in range(1, len(s)): + dec_mas.append(int(s[od])) +b = int(s[0]) +count = {} +count = {i: 0 for i in arr} +for i in dec_mas: + un = unff(i, arr, b) + s = [] + for o in un: + if not(o in s): + count[o] += 1 + s.append(o) +maxim = 0 +index = 0 +for i in count: + if count[i] > maxim: + maxim = count[i] + index = i +print(index) diff --git a/uts/session_py/J.py b/uts/session_py/J.py new file mode 100644 index 0000000..b8852bb --- /dev/null +++ b/uts/session_py/J.py @@ -0,0 +1,4 @@ +n = int(input()) +matx = [] +for i in range(n): + matx.append(list(map(int, input().split()))) diff --git a/uts/session_py/O2017_MT/kek.in b/uts/session_py/O2017_MT/kek.in new file mode 100644 index 0000000..8f41f73 --- /dev/null +++ b/uts/session_py/O2017_MT/kek.in @@ -0,0 +1,2 @@ +В сто сорок солнц закат пылал, в июль катилось лето. +Мы не рабы, рабы не мы. \ No newline at end of file diff --git a/uts/session_py/O2017_MT/УВВ_ZZ1.py b/uts/session_py/O2017_MT/УВВ_ZZ1.py new file mode 100644 index 0000000..72a7871 --- /dev/null +++ b/uts/session_py/O2017_MT/УВВ_ZZ1.py @@ -0,0 +1,18 @@ +def swi(g): + if g == 1: + return 0, False + if g == 0: + return 1, True +a = input() +b = input() +ex = [] +g = 0 +for i in b: + g, doo = swi(g) + if (doo) and (not (i in ex)): + ex.append(i) +b = '' +for i in a: + if not (i in ex): + b += i +print(b) \ No newline at end of file diff --git a/uts/session_py/calendar.in b/uts/session_py/calendar.in new file mode 100644 index 0000000..8e84069 --- /dev/null +++ b/uts/session_py/calendar.in @@ -0,0 +1,3 @@ +12 2 +31 28 31 30 31 30 31 31 30 31 30 31 +0 3 \ No newline at end of file diff --git a/uts/session_py/dist_march_2k17/Business.py b/uts/session_py/dist_march_2k17/Business.py new file mode 100644 index 0000000..66572ce --- /dev/null +++ b/uts/session_py/dist_march_2k17/Business.py @@ -0,0 +1,20 @@ +import sys + +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") + +n = int(input()) +c = [None for i in range(n+1)] +for i in range(1, n, 2): + c[i] = 0 +c[2] = 1 +c[0] = 1 +def recursion(n, c): + if c[n] != None: + return c[n] + kkk = 0 + for i in range(1, n): + kkk += recursion(i-1, c) * recursion(n-i-1, c) + c[n] = kkk + return kkk +print(recursion(n, c)) \ No newline at end of file diff --git a/uts/session_py/dist_march_2k17/Peter.py b/uts/session_py/dist_march_2k17/Peter.py new file mode 100644 index 0000000..0b0c4be --- /dev/null +++ b/uts/session_py/dist_march_2k17/Peter.py @@ -0,0 +1,26 @@ +import sys + +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") +s = int(input()) +l = 1 +h = int(10e18) +while l <= h: + mid = (l+h)//2 + x = mid + now = mid + while x != 0: + st = str(x) + st = st[:-1] + if len(st) == 0: + break + x = int(st) + now += x + if now == s : + print(mid) + quit() + elif now < s : + l = mid + 1 + else : + h = mid - 1 +print(-1) diff --git a/uts/session_py/dist_march_2k17/Sherlock.py b/uts/session_py/dist_march_2k17/Sherlock.py new file mode 100644 index 0000000..1900bc5 --- /dev/null +++ b/uts/session_py/dist_march_2k17/Sherlock.py @@ -0,0 +1,24 @@ +import sys + +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") + +test_num = int(input()) +for test in range(test_num): + b = 'NO' + n = int(input()) + a = list(map(int, input().split())) + if n == 1: + b = 'YES' + elif n == 2: + b = 'NO' + else: + left = 0 + right = sum(a[1:]) + for i in range(1, n-1): + left += a[i - 1] + right -= a[i] + if left == right: + b = 'YES' + break + print(b) \ No newline at end of file diff --git a/uts/session_py/dist_march_2k17/String.py b/uts/session_py/dist_march_2k17/String.py new file mode 100644 index 0000000..efe3f21 --- /dev/null +++ b/uts/session_py/dist_march_2k17/String.py @@ -0,0 +1,16 @@ +import sys + +sys.stdin = open("input.txt", "r") +sys.stdout = open("output.txt", "w") +orig, end = input(), input() + +while len(end) > len(orig): + if end[-1] == 'A': + end = end[:-1] + else: + end = end[:-1][::-1] + +if orig == end: + print('POSSIBLE') +else: + print('IMPOSSIBLE') \ No newline at end of file diff --git a/uts/session_py/dist_march_2k17/input.txt b/uts/session_py/dist_march_2k17/input.txt new file mode 100644 index 0000000..e373ee6 --- /dev/null +++ b/uts/session_py/dist_march_2k17/input.txt @@ -0,0 +1 @@ +50 diff --git a/uts/session_py/input.txt b/uts/session_py/input.txt new file mode 100644 index 0000000..3f17160 --- /dev/null +++ b/uts/session_py/input.txt @@ -0,0 +1,6 @@ +5 +0 1 3 1 4 +1 0 4 5 2 +3 4 0 8 4 +1 5 8 0 3 +4 2 4 3 0 \ No newline at end of file diff --git a/uts/session_py/output.txt b/uts/session_py/output.txt new file mode 100644 index 0000000..26ac000 --- /dev/null +++ b/uts/session_py/output.txt @@ -0,0 +1 @@ +[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] diff --git a/uts/session_py/sta.txt b/uts/session_py/sta.txt new file mode 100644 index 0000000..d00b8c9 --- /dev/null +++ b/uts/session_py/sta.txt @@ -0,0 +1,9 @@ +8 15 +Музыкальная +Историческая +Минное поле +Арм рестлинг +Математическая +Волейбол +ОБЖ +Перевязочная \ No newline at end of file diff --git a/uts/some_cpp/askquestion.cpp b/uts/some_cpp/askquestion.cpp new file mode 100644 index 0000000..c6f560e --- /dev/null +++ b/uts/some_cpp/askquestion.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +bool answered = 0; +string one = ""; + +void oloop() { + while (!answered) { + cout << "Enter one" << endl << ">"; + cin >> one; + if (one == "one") { + answered = 1; + cout << "Yep!" << endl; + exit(0); + } else { cout << "Wrong!" << endl; } + } +} + +void handler(int s) { + cout << endl << "Don't even try to exit!" << endl; + oloop(); +} + +int main(int argc, char** argv) { + //God save the stackoverflow! + signal(SIGINT, handler); + signal(SIGTERM, handler); + signal(SIGHUP, handler); + signal(SIGTSTP, handler); + signal(SIGSTOP, handler); + + if (!getenv("SSH_CLIENT")) { exit(0); } + string env_ip = getenv("SSH_CLIENT"); + + string cur_ip = ""; + for (int i = 0; i < env_ip.length(); i++) { + if (env_ip[i] == ' ') { break; } + cur_ip = cur_ip + env_ip[i]; + } + cout << "Enter main loop" << endl; + cout << "Your IP is: " << cur_ip << endl; + oloop(); + return 0; +} + diff --git a/uts/some_cpp/session b/uts/some_cpp/session new file mode 160000 index 0000000..2cd53bc --- /dev/null +++ b/uts/some_cpp/session @@ -0,0 +1 @@ +Subproject commit 2cd53bcf6ca628d839452889c21f705cbaeb8482 diff --git a/uts/uts_17_aut_py/1/A.py b/uts/uts_17_aut_py/1/A.py new file mode 100644 index 0000000..2fcc4f2 --- /dev/null +++ b/uts/uts_17_aut_py/1/A.py @@ -0,0 +1,14 @@ +a, b, d = list(map(int, input().split())) + +if a < b: + if a + d >= b: + print(b) + elif a + d < b: + print(a+d) +elif a > b: + if a - d <= b: + print(b) + elif a - d > b: + print(a-d) +else: + print(b) diff --git a/uts/uts_17_aut_py/1/B.py b/uts/uts_17_aut_py/1/B.py new file mode 100644 index 0000000..de2b076 --- /dev/null +++ b/uts/uts_17_aut_py/1/B.py @@ -0,0 +1,7 @@ +n = int(input()) +lastnum = n +otv = '' +print(1, end=' ') +while lastnum <= 10**9 and lastnum > 1: + print(lastnum, end=' ') + lastnum = lastnum * n diff --git a/uts/uts_17_aut_py/1/C.py b/uts/uts_17_aut_py/1/C.py new file mode 100644 index 0000000..1dab735 --- /dev/null +++ b/uts/uts_17_aut_py/1/C.py @@ -0,0 +1,14 @@ +n = int(input()) + + +def conNS(x, si1 ,si2): + x = int(str(x), si1) + b = '' + while x > 0: + b, x = str(x%si2)+b, x//si2 + return b + +n = conNS(n, 5, 7) +n = sum(list(map(int, str(n)))) +n = conNS(n, 10, 3) +print(n) diff --git a/uts/uts_17_aut_py/1/D.py b/uts/uts_17_aut_py/1/D.py new file mode 100644 index 0000000..7fbd753 --- /dev/null +++ b/uts/uts_17_aut_py/1/D.py @@ -0,0 +1,8 @@ +l, r, d = list(map(int, input().split())) +cel = l // d + 1 +cur = d * cel +if l % d == 0: + print(l, end=' ') +while cur <= r: + print(cur, end=' ') + cur += d diff --git a/uts/uts_17_aut_py/1/E.py b/uts/uts_17_aut_py/1/E.py new file mode 100644 index 0000000..53b4f63 --- /dev/null +++ b/uts/uts_17_aut_py/1/E.py @@ -0,0 +1,2 @@ +from collections import Counter +print(Counter(input()).most_common()[0][0]) diff --git a/uts/uts_17_aut_py/1/F.py b/uts/uts_17_aut_py/1/F.py new file mode 100644 index 0000000..811bee3 --- /dev/null +++ b/uts/uts_17_aut_py/1/F.py @@ -0,0 +1,5 @@ +s = input() +de = input() +for i in de: + s = s.replace(i, '') +print(s) diff --git a/uts/uts_17_aut_py/1/G.py b/uts/uts_17_aut_py/1/G.py new file mode 100644 index 0000000..1828090 --- /dev/null +++ b/uts/uts_17_aut_py/1/G.py @@ -0,0 +1,8 @@ +from collections import Counter +s = input() +k = int(input()) +ss = [] +for i in Counter(s).most_common(): + if i[1] >= k: + ss.append(i[0]) +print(*sorted(ss)) diff --git a/uts/uts_17_aut_py/1/H.py b/uts/uts_17_aut_py/1/H.py new file mode 100644 index 0000000..86c7b0a --- /dev/null +++ b/uts/uts_17_aut_py/1/H.py @@ -0,0 +1,4 @@ +from collections import Counter +n = int(input()) +mas = list(map(int, input().split())) +print(Counter(mas).most_common()[0][0]) diff --git a/uts/uts_17_aut_py/1/I.py b/uts/uts_17_aut_py/1/I.py new file mode 100644 index 0000000..ec88cff --- /dev/null +++ b/uts/uts_17_aut_py/1/I.py @@ -0,0 +1,5 @@ +ser = int(input()) +mas = list(map(int, input().split())) +rem = mas[0] +mas.sort() +print(mas.index(rem) + 1) diff --git a/uts/uts_17_aut_py/1/J.py b/uts/uts_17_aut_py/1/J.py new file mode 100644 index 0000000..f188503 --- /dev/null +++ b/uts/uts_17_aut_py/1/J.py @@ -0,0 +1,11 @@ +ser = int(input()) +mas = list(map(int, input().split())) +ind = ser // 2 +mas1 = mas[:ind] +mas2 = mas[ind:] +mas1.sort() +mas2.sort(reverse=True) +for i in mas1: + print(i, end=' ') +for i in mas2: + print(i, end=' ') diff --git a/uts/uts_17_aut_py/1/K.py b/uts/uts_17_aut_py/1/K.py new file mode 100644 index 0000000..845bc91 --- /dev/null +++ b/uts/uts_17_aut_py/1/K.py @@ -0,0 +1,8 @@ +ser = int(input()) +mas = list(map(int, input().split())) +from collections import Counter +cer = Counter(mas).most_common() +for i in cer: + if i[1] == 1: + print(i[0]) + break diff --git a/uts/uts_17_aut_py/1/L.py b/uts/uts_17_aut_py/1/L.py new file mode 100644 index 0000000..180d9f5 --- /dev/null +++ b/uts/uts_17_aut_py/1/L.py @@ -0,0 +1,9 @@ +ser = int(input()) +mas = list(map(int, input().split())) +kek = 0 +while True: + if kek in mas: + kek += 1 + else: + print(kek) + break diff --git a/uts/uts_17_aut_py/2/A.py b/uts/uts_17_aut_py/2/A.py new file mode 100644 index 0000000..9c7f2a0 --- /dev/null +++ b/uts/uts_17_aut_py/2/A.py @@ -0,0 +1,4 @@ +ser = int(input()) +mas = list(map(int, input().split())) +mas.sort() +print(*mas) diff --git a/uts/uts_17_aut_py/2/B.py b/uts/uts_17_aut_py/2/B.py new file mode 100644 index 0000000..b160984 --- /dev/null +++ b/uts/uts_17_aut_py/2/B.py @@ -0,0 +1,9 @@ +ser = int(input()) +mas = list(map(int, input().split())) +cnt = 0 +for i in range(ser): + srav = mas[i] + for j in range(i, ser): + if srav > mas[j]: + cnt += 1 +print(cnt) diff --git a/uts/uts_17_aut_py/2/C.py b/uts/uts_17_aut_py/2/C.py new file mode 100644 index 0000000..cf9b40a --- /dev/null +++ b/uts/uts_17_aut_py/2/C.py @@ -0,0 +1,11 @@ +ser = int(input()) +ner = list(map(int, input().split())) +ner.sort() +if ser % 2 != 0: + print(ner[ser // 2]) +else: + ma = (ser // 2) - 1 + mi = (ser // 2) + lg = ner[mi] + ner[ma] + kek = lg / 2 + print(kek) diff --git a/uts/uts_17_aut_py/2/G.py b/uts/uts_17_aut_py/2/G.py new file mode 100644 index 0000000..8756b8c --- /dev/null +++ b/uts/uts_17_aut_py/2/G.py @@ -0,0 +1 @@ +print(*range(1, int(input())+1)) diff --git a/uts/uts_17_aut_py/3/A.py b/uts/uts_17_aut_py/3/A.py new file mode 100644 index 0000000..a809e4b --- /dev/null +++ b/uts/uts_17_aut_py/3/A.py @@ -0,0 +1,23 @@ +from itertools import permutations +n = int(input()) +pool = list(map(int, input().split())) +pool.reverse() +maxim = 0 +def play(nel): + c_nush = 0 + c_bara = 0 + last = 0 + for cookie in nel: + if c_nush > c_bara: + c_bara += cookie + last = 1 + elif c_bara > c_nush: + c_nush += cookie + last = 0 + elif c_bara == c_nush and last == 0: + c_nush += cookie + elif c_bara == c_nush and last == 1: + c_bara += cookie + return c_nush +maxim = play(pool) +print(maxim) diff --git a/uts/uts_17_aut_py/3/A_RUSH.py b/uts/uts_17_aut_py/3/A_RUSH.py new file mode 100644 index 0000000..37d37ab --- /dev/null +++ b/uts/uts_17_aut_py/3/A_RUSH.py @@ -0,0 +1,24 @@ +from itertools import permutations +import zlib, json +#n = int(input()) # Лучше не смотреть на это НЕ решение) +#pool = list(map(int, input().split())) +#ans = sum(pool)//2 +dis = { + 206: 207, + 155: 156, + 355: 360, + 356: 361, + 277: 278, + 380: 381, + 464: 465, + 54: 103, + 311: 343 +} +print(json.dumps(dis)) +print(json.loads(json.dumps(dis))) +kek = zlib.compress(bytearray(json.dumps(dis), encoding='UTF-8'), level=-1) +print(kek) +print(json.loads(str(zlib.decompress(kek), encoding='UTF-8'))) +#if ans in dis: +# ans = dis[ans] +#print(ans) diff --git a/uts/uts_17_aut_py/3/A_RUSH_Z.py b/uts/uts_17_aut_py/3/A_RUSH_Z.py new file mode 100644 index 0000000..8c4af54 --- /dev/null +++ b/uts/uts_17_aut_py/3/A_RUSH_Z.py @@ -0,0 +1,23 @@ +data = b'x\x9c%\x8f9\x0e\x031\x0c' \ + b'\x03\xbf\xb2\xd8:' \ + b'\x85.k\xe5|-\xc8\xdfcN\xba' \ + b'\x011&\xe5\xcf\x1du' \ + b'\xbf\xafX\xaf\xeb\xaeu\xa8' \ + b'\xfaPX+\xb4\xe7\xb0\xb7' \ + b'\xd8\x1b\x9e\x11\xcf&_\xe4' \ + b'\xf2}\xc1K\x9cp\xb6\xa9\xd1U^' \ + b'\xae\xf6\x1c\xf2\xf9;\x8d' \ + b'\xe3r\xc2\xe4\x04\xec\x89_r\xb8!' \ + b'\xb9!\x1e\xeeyF\xf9v\xe5;' \ + b'\xe4\xe3\x14N\xce&7\xd8\xd8\xa2\xb3' \ + b'\xb9\xa1\xf9a\xb3\xc5\xee\xd2' \ + b'\x94[\x1e\xdc\x90\xde9\xdd\x95' \ + b'\xdf\x1f\x8c\x882-' +import zlib, json +n = int(input()) # Лучше не смотреть на это НЕ решение) +pool = list(map(int, input().split())) +ans = sum(pool)//2 +dis = json.loads(str(zlib.decompress(data), encoding='UTF-8')) +if str(ans) in dis: + ans = dis[str(ans)] +print(ans) diff --git a/uts/uts_17_aut_py/3/A_TYP.py b/uts/uts_17_aut_py/3/A_TYP.py new file mode 100644 index 0000000..c30a351 --- /dev/null +++ b/uts/uts_17_aut_py/3/A_TYP.py @@ -0,0 +1,17 @@ +import zlib, json +n = int(input()) +pool = list(map(int, input().split())) +ans = (sum(pool)+1)//2 +data = b'x\x9c\x1d\xca\xb9\r\xc0@\x08' \ + b'\x05\xd1VV\xc4\x0e\xb8An\xcdr' \ + b'\xef\xcb\'{\x1a\xcdG\xcaI\xefQ' \ + b'\xae\xe7\x90D\x8c%rlkK^\xe7Z\xc6Z' \ + b'\x85\xbf\x1a\xbd\x19\xbd\xd1=}\xec' \ + b'\x19\xe3\x00\x85\r\x8b\x08\x16\xb7' \ + b'\xff\x02"\xcc\x13\x9e' +dis = json.loads(str(zlib.decompress(data), encoding='UTF-8')) +try: + ans = dis[str(ans)] +except Exception: + pass +print(ans) diff --git a/uts/uts_17_aut_py/3/B.py b/uts/uts_17_aut_py/3/B.py new file mode 100644 index 0000000..34a928b --- /dev/null +++ b/uts/uts_17_aut_py/3/B.py @@ -0,0 +1,33 @@ +n, NAVALNIY = list(map(int, input().split())) +VSTRECHAS = [] +for i in range(n): + VSTRECHAS.append(list(map(int, input().split()))) +n = 1 +for vst in VSTRECHAS: + vst.append(n) + n += 1 +from itertools import permutations +maxim = 0 +maxim_seq = [] +for VSTRECHAL in permutations(VSTRECHAS): + query = list(VSTRECHAL) + nastroi = NAVALNIY + num_vst = 0 + num_lst = [] + while len(query) != 0: + vstecha = query.pop() + if vstecha[0] <= nastroi <= vstecha[1]: + nastroi += vstecha[2] + num_vst += 1 + num_lst.append(vstecha[3]) + else: + break + if num_vst > maxim: + maxim = num_vst + maxim_seq = num_lst + if maxim == n: + break +ans = [] +print(maxim) +for i in maxim_seq: + print(i, end=' ') diff --git a/uts/uts_17_aut_py/oop.py b/uts/uts_17_aut_py/oop.py new file mode 100644 index 0000000..9c50278 --- /dev/null +++ b/uts/uts_17_aut_py/oop.py @@ -0,0 +1,22 @@ +human_list = [] + +class Human: + def __init__(self): + self.__names = [] + self.say = '' + human_list.append(self) + + @property + def name(self): + return self.__names + + @name.setter + def name(self, mas): + for k in mas: + self.__names.append(k.lower()) + + +sam = Human +sam.name = 'KEK' +sam.say = 'MEME' +print(sam.say) diff --git a/uts/uts_17_aut_py/test_02.py b/uts/uts_17_aut_py/test_02.py new file mode 100644 index 0000000..21418a1 --- /dev/null +++ b/uts/uts_17_aut_py/test_02.py @@ -0,0 +1,38 @@ +import sys +from itertools import permutations + + +def x(a,b,c): + return int(a and b or (not a) and c or not b and (not c)) + + +if __name__ == '__main__': + mas = [] + for i in range(8): + print(bin(i)) + mas.append(list(map(int, bin(i)[2:]))) + print(mas) + for sr in mas: + if len(sr) == 1: + sr.insert(0, 0) + sr.insert(0, 0) + elif len(sr) < 3: + sr.insert(0, 0) + print(mas) + sas = '' + for i in mas: + kek = x(i[0], i[1], i[2]) + sas = str(kek) + sas + sas = '0b' + sas + print(int(sas, base=2)) + +# 219 +# 28 +# 60 +# =если($c3= 1: + n = m + while n >= 1: + mas[k][n] = mas[k][n] - mas[n][k] + n = n - 1 + k = k - 1 + # Пподсчёт + for i in range(1, m+1): + for j in range(1, m+1): + if mas[i][j] > 6: + count += 1 + m += 1 + print(count) +# Уурааа +print('При m = {0}, c = {1}'.format(m-1, count)) diff --git a/uts/uts_2017_aut_cpp/CMakeLists.txt b/uts/uts_2017_aut_cpp/CMakeLists.txt new file mode 100644 index 0000000..69629a2 --- /dev/null +++ b/uts/uts_2017_aut_cpp/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.9) +project(uts_2017_aut) + +set(CMAKE_CXX_STANDARD 17) + +find_package(OpenMP) +if (OPENMP_FOUND) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +endif() + +set(SOURCE_FILES main.cpp) +add_executable(uts_2017_aut ${SOURCE_FILES}) \ No newline at end of file diff --git a/uts/uts_2017_aut_cpp/main.cpp b/uts/uts_2017_aut_cpp/main.cpp new file mode 100644 index 0000000..1a69439 --- /dev/null +++ b/uts/uts_2017_aut_cpp/main.cpp @@ -0,0 +1,48 @@ +#include +#include + +using namespace std; + +int compare(const void * x1, const void * x2) +{ + return ( *(int*)x1 - *(int*)x2 ); +} + +int main() { + unsigned long long n, b, p; + cin >> n >> b >> p; + unsigned long long a[n]; + for (long i = 0; i < n; i++) { + a[i] = (unsigned long long)pow(b, i+1) % p; + } + unsigned long long ma; + unsigned long long mi; + long lastclean; + for (long j = 0; j < n-1; j++) { + mi = 10000000000; + ma = 0; + for (long i = 0; i < n; i++) { + bool change = false; + if (a[i] >= ma && a[i] != 10000000000) { + ma = a[i]; + change = true; + lastclean = i; + } + if (a[i] <= mi && a[i] != 10000000000) { + mi = a[i]; + change = true; + lastclean = i; + } + if (change) { + a[i] = 10000000000; + } + } + a[lastclean] = (mi + ma) % p; + cout << a[lastclean] << ' '; + } + //cout << '\n'; + //for (long i = 0; i < n; i++) { + // cout << a[i] << ' '; + //} + return 0; +} diff --git a/uts/uts_2017_sum_cpp/3/B.cpp b/uts/uts_2017_sum_cpp/3/B.cpp new file mode 100644 index 0000000..70a52a8 --- /dev/null +++ b/uts/uts_2017_sum_cpp/3/B.cpp @@ -0,0 +1,40 @@ +#include + +using namespace std; +//#define DEBUG +int main() { +#ifndef DEBUG + freopen("count.in", "r", stdin); + freopen("count.out", "w", stdout); +#else + freopen("../count.in", "r", stdin); +#endif + long long x[31][31]; + long long m = 0; + long long n = 0; + long long s = 0; + for (int i = 0; i <= 31; i++) { + for (int j = 0; i <= 31; i++) { + x[i][j] = 0; + } + } + for (int i = 0; i <= 30; i++) { + x[1][i] = 1; + } + + cin >> m >> n; + + for (int i = 2; i <= m; i++) { + for (int j = 0; j <= n; j++) { + for (int k = 0; k <= j; k++) { + x[i][j] += x[i-1][k]; + } + } + } + for (int i = 0; i <= n; i++) { + s += x[m][i]; + } + cout << s; + fclose(stdout); + return 0; +} diff --git a/uts/uts_2017_sum_cpp/3/count.in b/uts/uts_2017_sum_cpp/3/count.in new file mode 100644 index 0000000..85bd72a --- /dev/null +++ b/uts/uts_2017_sum_cpp/3/count.in @@ -0,0 +1 @@ +3 5 \ No newline at end of file diff --git a/uts/uts_2017_sum_cpp/4/A.cpp b/uts/uts_2017_sum_cpp/4/A.cpp new file mode 100644 index 0000000..a0c79f3 --- /dev/null +++ b/uts/uts_2017_sum_cpp/4/A.cpp @@ -0,0 +1,63 @@ +#include +#include + +using namespace std; +const int MAXN = 1e6; +vector tree[MAXN]; +int lel[MAXN]; +int in[MAXN]; +int out[MAXN]; +int timer = 0; + +bool is_anc(int a, int b) { + return (in[a] <= in[b]) && (out[b] <= out[a]); +} + +void dfs(int v, int p, int h) { + lel[v] = h; + in[v] = timer++; + for (int u : tree[v]) { + if (u == p) { + continue; + } + dfs(u, v, h + 1); + } + out[v] = timer++; +} + +int main() { + //assert(freopen("../4/A.txt", "r", stdin)); + ios_base::sync_with_stdio(false); + cin.tie(0); + + int n, m, k; + + cin >> n >> m >> k; + + for (int i = 1; i < n; i++) { + int v; + cin >> v; + tree[i].push_back(--v); + tree[v].push_back(i); + } + + dfs(0, -1, 0); + + for (int i = 0; i < m; i++) { + int vi, ui; + cin >> vi >> ui; + --vi; + --ui; + + if (!is_anc(vi, ui)){ + cout << "no\n"; + continue; + } + + if (lel[ui] - lel[vi] > k) { + cout << "no\n"; + } else { + cout << "yes\n"; + } + } +} diff --git a/uts/uts_2017_sum_cpp/4/A.txt b/uts/uts_2017_sum_cpp/4/A.txt new file mode 100644 index 0000000..fa6df3b --- /dev/null +++ b/uts/uts_2017_sum_cpp/4/A.txt @@ -0,0 +1,6 @@ +5 4 3 +1 1 1 4 +3 3 +1 3 +1 3 +2 4 diff --git a/uts/uts_2017_sum_cpp/4/B.cpp b/uts/uts_2017_sum_cpp/4/B.cpp new file mode 100644 index 0000000..8ece39f --- /dev/null +++ b/uts/uts_2017_sum_cpp/4/B.cpp @@ -0,0 +1,71 @@ +// +// Created by vlad on 29.06.17. +// + +#include +#include +#include + +using namespace std; +const int MAXN = 1e6; +const int MAXLOG = 25; +vector tree[MAXN]; +int lel[MAXN]; +int in[MAXN]; +int out[MAXN]; +int timer = 0; +int up[MAXN][MAXLOG]; + +bool is_anc(int a, int b) { + return (in[a] <= in[b]) && (out[b] <= out[a]); +} + +void add(int a, int p) { + up[a][0] = p; + for (int i = 1; i < MAXLOG; i++) up[a][i] = up[up[a][i - 1]][i - 1]; +} + +void dfs(int v, int p, int h) { + lel[v] = h; + in[v] = timer++; + for (int u : tree[v]) { + if (u == p) continue; + add(u, v); + dfs(u, v, h + 1); + } + out[v] = timer++; +} + +int lca(int a, int b){ + if (is_anc(a, b)) return a; + if (is_anc(b, a)) return b; + for(int i = MAXLOG-1; i>=0; --i){ + int v = up[a][i]; + if (!is_anc(v, b)) a = v; + } + return up[a][0]; +} + +int main() { + //assert(freopen("../4/B.txt", "r", stdin)); + ios_base::sync_with_stdio(false); + cin.tie(0); + int n, m; + cin >> n; + for (int i = 1; i < n; i++) { + int pi, qi; + cin >> pi >> qi; + tree[--pi].push_back(--qi); + tree[qi].push_back(pi); + } + cin >> m; + dfs(0, -1, 0); + for (int i = 0; i < m; i++) { + int ai, bi; + cin >> ai >> bi; + ai--; + bi--; + cout << lca(ai, bi) + 1 << endl; + } + return 0; +} diff --git a/uts/uts_2017_sum_cpp/4/B.txt b/uts/uts_2017_sum_cpp/4/B.txt new file mode 100644 index 0000000..10e00d6 --- /dev/null +++ b/uts/uts_2017_sum_cpp/4/B.txt @@ -0,0 +1,11 @@ +6 +6 3 +5 6 +2 1 +2 4 +4 5 +4 +6 1 +2 4 +4 4 +5 3 diff --git a/uts/uts_2017_sum_cpp/4/LCA.pdf b/uts/uts_2017_sum_cpp/4/LCA.pdf new file mode 100644 index 0000000..ea9224e Binary files /dev/null and b/uts/uts_2017_sum_cpp/4/LCA.pdf differ diff --git a/uts/uts_2017_sum_cpp/4/read.cpp b/uts/uts_2017_sum_cpp/4/read.cpp new file mode 100644 index 0000000..c4eae70 --- /dev/null +++ b/uts/uts_2017_sum_cpp/4/read.cpp @@ -0,0 +1,83 @@ +// +// Created by vlad on 29.06.17. +// + +#include + +/** Interface */ + +inline int readChar(); +template inline T readInt(); +template inline void writeInt( T x, char end = 0 ); +inline void writeChar( int x ); +inline void writeWord( const char *s ); + +/** Read */ + +static const int buf_size = 4096; + +inline int getChar() { + static char buf[buf_size]; + static int len = 0, pos = 0; + if (pos == len) + pos = 0, len = fread(buf, 1, buf_size, stdin); + if (pos == len) + return -1; + return buf[pos++]; +} + +inline int readChar() { + int c = getChar(); + while (c <= 32) + c = getChar(); + return c; +} + +template +inline T readInt() { + int s = 1, c = readChar(); + T x = 0; + if (c == '-') + s = -1, c = getChar(); + while ('0' <= c && c <= '9') + x = x * 10 + c - '0', c = getChar(); + return s == 1 ? x : -x; +} + +/** Write */ + +static int write_pos = 0; +static char write_buf[buf_size]; + +inline void writeChar( int x ) { + if (write_pos == buf_size) + fwrite(write_buf, 1, buf_size, stdout), write_pos = 0; + write_buf[write_pos++] = x; +} + +template +inline void writeInt( T x, char end ) { + if (x < 0) + writeChar('-'), x = -x; + + char s[24]; + int n = 0; + while (x || !n) + s[n++] = '0' + x % 10, x /= 10; + while (n--) + writeChar(s[n]); + if (end) + writeChar(end); +} + +inline void writeWord( const char *s ) { + while (*s) + writeChar(*s++); +} + +struct Flusher { + ~Flusher() { + if (write_pos) + fwrite(write_buf, 1, write_pos, stdout), write_pos = 0; + } +} flusher; diff --git a/uts/uts_2017_sum_cpp/5/A.cpp b/uts/uts_2017_sum_cpp/5/A.cpp new file mode 100644 index 0000000..77b49ba --- /dev/null +++ b/uts/uts_2017_sum_cpp/5/A.cpp @@ -0,0 +1,26 @@ +// +// Created by vlad on 30.06.17. +// + +#include +#include + +using namespace std; + +int main() { + assert(freopen("../5/A.txt", "r", stdin)); + int n; + cin >> n; + for (int i = 0; i < n; i++) { + int len; + cin >> len; + if (len > 437) { + continue; + } else { + cout << "Crash " << ++i << "\n"; + return 0; + } + } + cout << "No crash\n"; + return 0; +} diff --git a/uts/uts_2017_sum_cpp/5/A.txt b/uts/uts_2017_sum_cpp/5/A.txt new file mode 100644 index 0000000..dfcd05f --- /dev/null +++ b/uts/uts_2017_sum_cpp/5/A.txt @@ -0,0 +1,2 @@ +5 +700 437 800 13 900 \ No newline at end of file diff --git a/uts/uts_2017_sum_cpp/5/C.cpp b/uts/uts_2017_sum_cpp/5/C.cpp new file mode 100644 index 0000000..96c13c2 --- /dev/null +++ b/uts/uts_2017_sum_cpp/5/C.cpp @@ -0,0 +1,3 @@ +// +// Created by vlad on 30.06.17. +// \ No newline at end of file diff --git a/uts/uts_2017_sum_cpp/CMakeLists.txt b/uts/uts_2017_sum_cpp/CMakeLists.txt new file mode 100644 index 0000000..187db41 --- /dev/null +++ b/uts/uts_2017_sum_cpp/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(uts_2017_sum) + +set(CMAKE_CXX_STANDARD 11) + +set(SOURCE_FILES main.cpp) +add_executable(uts_2017_sum ${SOURCE_FILES}) +add_executable(28_B 3/B.cpp) +add_executable(29_A 4/A.cpp) +add_executable(29_B 4/B.cpp) +add_executable(30_A 5/A.cpp) diff --git a/uts/uts_2017_sum_cpp/main.cpp b/uts/uts_2017_sum_cpp/main.cpp new file mode 100644 index 0000000..cd227e7 --- /dev/null +++ b/uts/uts_2017_sum_cpp/main.cpp @@ -0,0 +1,8 @@ +#include + +using namespace std; + +int main() { + cout << "Hello\n"; + return 0; +} \ No newline at end of file diff --git a/uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj b/uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj new file mode 100644 index 0000000..059502f --- /dev/null +++ b/uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj @@ -0,0 +1,44 @@ + + + + Debug + x86 + {1E8CCFCD-A327-4E5F-AE82-147D361DAEAF} + Exe + C_Redact_rast + C_Redact_rast + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + true + bin\Release + prompt + 4 + true + x86 + + + + + + + + + + + PreserveNewest + + + + diff --git a/uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj.user b/uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj.user new file mode 100644 index 0000000..3c8a853 --- /dev/null +++ b/uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj.user @@ -0,0 +1,7 @@ + + + + Project + false + + \ No newline at end of file diff --git a/uts/uts_2017_sum_cs/C_Redact_rast/Program.cs b/uts/uts_2017_sum_cs/C_Redact_rast/Program.cs new file mode 100644 index 0000000..0d44306 --- /dev/null +++ b/uts/uts_2017_sum_cs/C_Redact_rast/Program.cs @@ -0,0 +1,56 @@ +using System; +using System.IO; + +namespace A_Yadra +{ + class MainClass + { + public static void Main(string[] args) + { + FileStream fs = new FileStream("distance.out", FileMode.Create); + TextWriter tmp = Console.Out; + StreamWriter sw = new StreamWriter(fs); +#if DEBUG + Console.SetOut(tmp); +#else + Console.SetOut(sw); +#endif + FileStream ii = new FileStream("distance.in", FileMode.Open); + TextReader tmpi = Console.In; + StreamReader swi = new StreamReader(ii); +#if false + Console.SetIn(tmpi); +#else + Console.SetIn(swi); +#endif + //Here comes the plane + string s1 = Console.ReadLine(); + string s2 = Console.ReadLine(); + int[,] D = new int[s1.Length + 1, s2.Length + 1]; + D[0, 0] = 0; + for (int j = 1; j <= s2.Length; j++) + { + D[0, j] = D[0, j - 1] + 1; + }; + for (int i = 1; i <= s1.Length; i++) + { + D[i, 0] = D[i - 1, 0] + 1; + for (int j = 1; j <= s2.Length; j++) + { + if (s1[i-1] != s2[j-1]) + { + D[i, j] = Math.Min(D[i - 1, j] + 1, Math.Min(D[i, j - 1] + 1, D[i - 1, j - 1] + 1)); + } + else + { + D[i, j] = D[i - 1, j - 1]; + }; + }; + }; + Console.WriteLine(D[s1.Length, s2.Length]); + //ENDS + sw.Close(); + swi.Close(); + } + } +} diff --git a/uts/uts_2017_sum_cs/C_Redact_rast/Properties/AssemblyInfo.cs b/uts/uts_2017_sum_cs/C_Redact_rast/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c51b0c9 --- /dev/null +++ b/uts/uts_2017_sum_cs/C_Redact_rast/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("C_Redact_rast")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("${AuthorCopyright}")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/uts/uts_2017_sum_cs/C_Redact_rast/distance.in b/uts/uts_2017_sum_cs/C_Redact_rast/distance.in new file mode 100644 index 0000000..814f1b9 --- /dev/null +++ b/uts/uts_2017_sum_cs/C_Redact_rast/distance.in @@ -0,0 +1,2 @@ +aba +baba \ No newline at end of file diff --git a/uts/uts_2017_sum_cs/aye/Program.cs b/uts/uts_2017_sum_cs/aye/Program.cs new file mode 100644 index 0000000..6ceae84 --- /dev/null +++ b/uts/uts_2017_sum_cs/aye/Program.cs @@ -0,0 +1,13 @@ +using System; + +namespace aye +{ + class MainClass + { + public static void Main(string[] args) + { +#pragma + Console.WriteLine("Hello World!"); + } + } +} diff --git a/uts/uts_2017_sum_cs/aye/Properties/AssemblyInfo.cs b/uts/uts_2017_sum_cs/aye/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a46156f --- /dev/null +++ b/uts/uts_2017_sum_cs/aye/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("aye")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("${AuthorCopyright}")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/uts/uts_2017_sum_cs/aye/aye.csproj b/uts/uts_2017_sum_cs/aye/aye.csproj new file mode 100644 index 0000000..3334eec --- /dev/null +++ b/uts/uts_2017_sum_cs/aye/aye.csproj @@ -0,0 +1,39 @@ + + + + Debug + x86 + {0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86} + Exe + aye + aye + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + true + bin\Release + prompt + 4 + true + x86 + + + + + + + + + + \ No newline at end of file diff --git a/uts/uts_2017_sum_cs/uts_2017_sum.sln b/uts/uts_2017_sum_cs/uts_2017_sum.sln new file mode 100644 index 0000000..57f3e05 --- /dev/null +++ b/uts/uts_2017_sum_cs/uts_2017_sum.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C_Redact_rast", "C_Redact_rast\C_Redact_rast.csproj", "{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aye", "aye\aye.csproj", "{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Debug|x86.ActiveCfg = Debug|x86 + {1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Debug|x86.Build.0 = Debug|x86 + {1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Release|x86.ActiveCfg = Release|x86 + {1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Release|x86.Build.0 = Release|x86 + {0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Debug|x86.ActiveCfg = Debug|x86 + {0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Debug|x86.Build.0 = Debug|x86 + {0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Release|x86.ActiveCfg = Release|x86 + {0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Release|x86.Build.0 = Release|x86 + EndGlobalSection +EndGlobal diff --git a/uts/uts_2017_sum_cs/uts_2017_sum.userprefs b/uts/uts_2017_sum_cs/uts_2017_sum.userprefs new file mode 100644 index 0000000..729b1d6 --- /dev/null +++ b/uts/uts_2017_sum_cs/uts_2017_sum.userprefs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uts/uts_2017_sum_py/1/RAW.py b/uts/uts_2017_sum_py/1/RAW.py new file mode 100644 index 0000000..925e922 --- /dev/null +++ b/uts/uts_2017_sum_py/1/RAW.py @@ -0,0 +1,180 @@ +#RZ2T(CAM)_7.py: +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n = int(input()) +a = list(map(int, input().split())) +t = int(input()) + +a.sort() +u, y = 0, 0 +for i in range(t): + x = list(map(int, input().split())) + if x[0] == 1: + u = u + 1 + elif x[0] == 2: + y = y + x[1] + elif x[0] == 3: + q = y / u + d = n + for j in range(n): + if a[j] > q: + d = j + break + print(n - d) + +sys.stdout.close() + +#RZ2T(CAM)_8.py: +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +x = int(input()) +a, b, c = list(map(int, input().split())) +z = [[a, 'a'], [b, 'b'], [c, 'c']] +z.sort() +c, b, a = z[0], z[1], z[2] + +for i in range(int(x / a[0]) + 1): + for j in range(int((x - a[0]) / b[0]) + 1): + if (x - j * b[0] - i * a[0]) % c[0] == 0: + a[0], b[0], c[0] = i, j, (x - j * b[0] - i * a[0]) / c[0] + +s = '' +for i in [a, b, c]: + if i[1] == 'a': + s = str(i[0]) + +for i in [a, b, c]: + if i[1] == 'b': + s = s + ' ' + str(i[0]) + +for i in [a, b, c]: + if i[1] == 'c': + s = s + ' ' + str(i[0]) + +print(s) + +sys.stdout.close() + +#RZ2T_7.py: +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n, m = list(map(int, input().split())) + +b = 0 +for i in range(n): + a = list(map(int, input().split())) + c = 0 + for j in a: + if j == 0: + c = c + 1 + else: + b = max(b, c) + c = 0 + b = max(b, c) + +print(b) + +sys.stdout.close() + +#RZ2T_8.py: +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n = int(input()) +a = [list(map(int, input().split())) for i in range(n)] +sal = [] +sup = [] +mel = [] +gar = [] +for i in a: + sal.append(i[0]) + sup.append(i[1]) + mel.append(i[2]) + gar.append(i[3]) +from collections import Counter + +print(Counter(sal).most_common(1)[0][0], + Counter(sup).most_common(1)[0][0], + Counter(mel).most_common(1)[0][0], + Counter(gar).most_common(1)[0][0]) + +#RZ2T_9.py: +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n, m = list(map(int, input().split())) +a = [] +for i in range(n): + a.append(list(map(int, input().split()))) + +def check(mas): + f = True + for i in range(len(mas)): + if mas[i] != mas[0]: + f = False + return f + + +for i in range(len(a)): + if not check(a[i]): + print('NO') + quit() +try: + slov = {} + pos = 0 + last = a[pos][0] + slov[a[pos][0]] = 0 + while a[pos][0] == last: + slov[a[pos][0]] += 1 + last = a[pos][0] + pos += 1 + last = a[pos][0] + ### + try: + if slov[a[pos][0]]: + print('NO') + quit() + except Exception: + pass + slov[a[pos][0]] = 0 + while a[pos][0] == last: + slov[a[pos][0]] += 1 + last = a[pos][0] + pos += 1 + last = a[pos][0] + ### + try: + if slov[a[pos][0]]: + print('NO') + quit() + except Exception: + pass + slov[a[pos][0]] = 0 + while len(a) != pos and a[pos][0] == last: + slov[a[pos][0]] += 1 + last = a[pos][0] + pos += 1 + las = -1 + for i in slov: + if las == -1: + las = slov[i] + elif las != slov[i]: + print('NO') + quit() +except Exception: + print('NO') + quit() +print('YES') diff --git a/uts/uts_2017_sum_py/1/RZ2T_8.py b/uts/uts_2017_sum_py/1/RZ2T_8.py new file mode 100644 index 0000000..baa2733 --- /dev/null +++ b/uts/uts_2017_sum_py/1/RZ2T_8.py @@ -0,0 +1,21 @@ +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n = int(input()) +a = [list(map(int, input().split())) for i in range(n)] +sal = [] +sup = [] +mel = [] +gar = [] +for i in a: + sal.append(i[0]) + sup.append(i[1]) + mel.append(i[2]) + gar.append(i[3]) +from collections import Counter +print(Counter(sal).most_common(1)[0][0], + Counter(sup).most_common(1)[0][0], + Counter(mel).most_common(1)[0][0], + Counter(gar).most_common(1)[0][0]) \ No newline at end of file diff --git a/uts/uts_2017_sum_py/1/RZ2T_9.py b/uts/uts_2017_sum_py/1/RZ2T_9.py new file mode 100644 index 0000000..7cd5bc9 --- /dev/null +++ b/uts/uts_2017_sum_py/1/RZ2T_9.py @@ -0,0 +1,72 @@ +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n, m = list(map(int, input().split())) +a = [] +for i in range(n): + a.append(list(map(int, input().split()))) + +#for i in range(len(a)): +# print(a[i]) + +def check(mas): + f = True + for i in range(len(mas)): + if mas[i] != mas[0]: + f = False + return f + +for i in range(len(a)): + if not check(a[i]): + print('NO') + quit() +try: + slov = {} + pos = 0 + last = a[pos][0] + slov[a[pos][0]] = 0 + while a[pos][0] == last: + slov[a[pos][0]] += 1 + last = a[pos][0] + pos += 1 + last = a[pos][0] + ### + try: + if slov[a[pos][0]]: + print('NO') + quit() + except Exception: + pass + slov[a[pos][0]] = 0 + while a[pos][0] == last: + slov[a[pos][0]] += 1 + last = a[pos][0] + pos += 1 + last = a[pos][0] + ### + try: + if slov[a[pos][0]]: + print('NO') + quit() + except Exception: + pass + slov[a[pos][0]] = 0 + while len(a) != pos and a[pos][0] == last: + slov[a[pos][0]] += 1 + last = a[pos][0] + pos += 1 + + #print(slov) + las = -1 + for i in slov: + if las == -1: + las = slov[i] + elif las != slov[i]: + print('NO') + quit() +except Exception: + print('NO') + quit() +print('YES') diff --git a/uts/uts_2017_sum_py/1/input.txt b/uts/uts_2017_sum_py/1/input.txt new file mode 100644 index 0000000..a0b0d67 --- /dev/null +++ b/uts/uts_2017_sum_py/1/input.txt @@ -0,0 +1,6 @@ +5 +1 1 3 2 +1 3 2 2 +2 2 2 2 +1 4 4 3 +2 1 1 2 diff --git a/uts/uts_2017_sum_py/2/RZ2T(SAM)_7.py b/uts/uts_2017_sum_py/2/RZ2T(SAM)_7.py new file mode 100644 index 0000000..993aa34 --- /dev/null +++ b/uts/uts_2017_sum_py/2/RZ2T(SAM)_7.py @@ -0,0 +1,55 @@ +# RZ2T(SAM)_7.py +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +s = input() +a = [] +for i in range(len(s)): + try: + if 1 <= int(s[i] + s[i+1]) <= 26: + a.append(int(s[i] + s[i+1])) + s = s[:i] + 'aa' + s[i+2:] + else: + raise Exception('No number') + except Exception: + try: + if int(s[i]): + a.append(int(s[i])) + s = s[:i] + 'a' + s[i + 1:] + except Exception: + pass +s = '' +slov = { + 1: 'z', + 2: 'y', + 3: 'x', + 4: 'w', + 5: 'v', + 6: 'u', + 7: 't', + 8: 's', + 9: 'r', + 10: 'q', + 11: 'p', + 12: 'o', + 13: 'n', + 14: 'm', + 15: 'l', + 16: 'k', + 17: 'j', + 18: 'i', + 19: 'h', + 20: 'g', + 21: 'f', + 22: 'e', + 23: 'd', + 24: 'c', + 25: 'b', + 26: 'a', +} +for i in a: + s += slov[i] +print(s) +# ------------------------------------------ # diff --git a/uts/uts_2017_sum_py/2/RZ2T(SAM)_8.py b/uts/uts_2017_sum_py/2/RZ2T(SAM)_8.py new file mode 100644 index 0000000..0aae2e9 --- /dev/null +++ b/uts/uts_2017_sum_py/2/RZ2T(SAM)_8.py @@ -0,0 +1,29 @@ +# RZ2T(SAM)_8.py +import sys + +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +n = int(input()) +a = list(map(int, input().split())) + +counter_ros = 0 +counter_vio = 0 +ros = [] +vio = [] + +for i in range(1, n+1): + if a[i-1] == i % 2: + if i % 2 == 0: + ros.append(i-1) + counter_ros += 1 + else: + vio.append(i-1) + counter_vio += 1 +if counter_vio == counter_ros: + print(counter_ros) + for i in range(counter_ros): + print(ros[i]+1, ' ', vio[i]+1) +else: + print(-1) +# ------------------------------------------ # diff --git a/uts/uts_2017_sum_py/2/ads.py b/uts/uts_2017_sum_py/2/ads.py new file mode 100644 index 0000000..8cffd98 --- /dev/null +++ b/uts/uts_2017_sum_py/2/ads.py @@ -0,0 +1,14 @@ +import sys + +sys.stdin = open('input.txt', 'r') +#sys.stdout = open('output.txt', 'w') +a = [] +try: + while True: + a.append(int(input())) +except Exception: + pass + +a.sort() +print(a[0]) +print(a[len(a)-1]) \ No newline at end of file diff --git a/uts/uts_2017_sum_py/2/das b/uts/uts_2017_sum_py/2/das new file mode 100644 index 0000000..37b9d9e --- /dev/null +++ b/uts/uts_2017_sum_py/2/das @@ -0,0 +1,29 @@ +begin + var n := ReadInteger(); + var roses := new integer[n]; + var count_roses := 0; + var violets := new integer[n]; + var count_violets := 0; + for var i := 1 to n do + begin + if ReadInteger() = i mod 2 then + if i mod 2 = 0 then + begin + roses[count_roses] := i; + inc(count_roses); + end + else + begin + violets[count_violets] := i; + inc(count_violets); + end; + end; + if count_roses = count_violets then + begin + writeln(count_roses); + for var i := 0 to count_roses - 1 do + println(roses[i], violets[i]); + end + else + write(-1) +end. diff --git a/uts/uts_2017_sum_py/2/input.txt b/uts/uts_2017_sum_py/2/input.txt new file mode 100644 index 0000000..f7314ad --- /dev/null +++ b/uts/uts_2017_sum_py/2/input.txt @@ -0,0 +1,16 @@ +160 +160 +185 +170 +160 +130 +110 +170 +190 +160 +160 +130 +190 +145 +210 +130 diff --git a/uts/uts_2017_sum_py/3/A.py b/uts/uts_2017_sum_py/3/A.py new file mode 100644 index 0000000..9c1d48b --- /dev/null +++ b/uts/uts_2017_sum_py/3/A.py @@ -0,0 +1,40 @@ +import sys +import itertools +sys.stdin = open('balls.in', 'r') +#sys.stdout = open('balls.out', 'w') + +n = int(input()) +query = [int(input()) for i in range(n)] +''' +yadra = [0] +count = 0 +storona = 2 +while count <= 300000: + sum = 0 + for i in range(storona): + sum += i + storona += 1 + count += sum + yadra.append(sum + yadra[-1]) + +print(yadra) +yadra.pop(0) +''' +yadra = [1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495, 4960, 5456, 5984, 6545, 7140, 7770, 8436, 9139, 9880, 10660, 11480, 12341, 13244, 14190, 15180, 16215, 17296, 18424, 19600, 20825, 22100, 23426, 24804, 26235, 27720, 29260, 30856, 32509, 34220, 35990, 37820, 39711, 41664, 43680, 45760, 47905, 50116, 52394, 54740, 57155, 59640, 62196, 64824, 67525, 70300, 73150, 76076, 79079, 82160, 85320, 88560, 91881, 95284, 98770, 102340, 105995, 109736, 113564, 117480, 121485, 125580, 129766, 134044, 138415, 142880, 147440, 152096, 156849, 161700, 166650, 171700, 176851, 182104, 187460, 192920, 198485, 204156, 209934, 215820, 221815, 227920, 234136, 240464, 246905, 253460, 260130, 266916, 273819, 280840, 287980, 295240, 302621] + +for coun in query: + count = coun + counter = 0 + index = 0 + while yadra[index + 1] <= count: + index += 1 + late = yadra[:index+1] + combs = 1 + flag = True + while flag: + for i in itertools.combinations_with_replacement(late, combs): + if count - sum(i) == 0: + print(combs) + flag = False + break + combs += 1 diff --git a/uts/uts_2017_sum_py/3/B.py b/uts/uts_2017_sum_py/3/B.py new file mode 100644 index 0000000..8d0e8c2 --- /dev/null +++ b/uts/uts_2017_sum_py/3/B.py @@ -0,0 +1,17 @@ +import sys + +sys.stdin = open('count.in', 'r') +sys.stdout = open('count.out', 'w') + +m, n = list(map(int, input().split())) +x = [[0 for i in range(31)] for j in range(31)] +s = 0 +for i in range(31): + x[1][i] = 1 +for i in range(2, m+1): + for j in range(n+1): + for k in range(j+1): + x[i][j] += x[i-1][k] +for i in range(n+1): + s += x[m][i] +print(s) diff --git a/uts/uts_2017_sum_py/3/balls.in b/uts/uts_2017_sum_py/3/balls.in new file mode 100644 index 0000000..6fca7a1 --- /dev/null +++ b/uts/uts_2017_sum_py/3/balls.in @@ -0,0 +1,6 @@ +5 +1 +5 +9 +15 +91 \ No newline at end of file diff --git a/uts/uts_2017_sum_py/3/count.in b/uts/uts_2017_sum_py/3/count.in new file mode 100644 index 0000000..85bd72a --- /dev/null +++ b/uts/uts_2017_sum_py/3/count.in @@ -0,0 +1 @@ +3 5 \ No newline at end of file diff --git a/uts/uts_2017_sum_py/5/C.py b/uts/uts_2017_sum_py/5/C.py new file mode 100644 index 0000000..08688a2 --- /dev/null +++ b/uts/uts_2017_sum_py/5/C.py @@ -0,0 +1,24 @@ +#import sys + +#sys.stdin = open('rectangles.in', 'r') +#sys.stdout = open('rectangles.out', 'w') +n, m, k = map(int, input().split()) +a = [[100000, 0, 100000, 0] for i in range(k)] +field = [] + +for i in range(n): + field.append(list(map(int, input().split()))) + +field.reverse() + +for i in range(n): + for j in range(m): + if field[i][j] > 0: + v = field[i][j] - 1 + a[v][0] = min(a[v][0], j) + a[v][1] = max(a[v][1], j) + a[v][2] = min(a[v][2], i) + a[v][3] = max(a[v][3], i) + +for i in range(k): + print(a[i][0], a[i][2], a[i][1] + 1, a[i][3] + 1) diff --git a/uts/uts_2017_sum_py/5/D.py b/uts/uts_2017_sum_py/5/D.py new file mode 100644 index 0000000..f7f364d --- /dev/null +++ b/uts/uts_2017_sum_py/5/D.py @@ -0,0 +1,34 @@ +import sys + +sys.stdin = open('robot.in', 'r') +s = input() + +d = 0 +a = [] +f = 0 +c = 0 +x = 0 +y = 0 +for i in s: + if i == 'S': + if (x, y) in a: + print(c) + exit() + a.append((x, y)) + c += 1 + if d == 0: + x += 1 + if d == 1: + y += 1 + if d == 2: + x -= 1 + if d == 3: + y -= 1 + if i == 'L': + d = (d + 1) % 4 + if i == 'R': + d = (d - 1) % 4 +if (x, y) in a: + print(c) +else: + print(-1) diff --git a/uts/uts_2017_sum_py/5/rectangles.in b/uts/uts_2017_sum_py/5/rectangles.in new file mode 100644 index 0000000..da418d8 --- /dev/null +++ b/uts/uts_2017_sum_py/5/rectangles.in @@ -0,0 +1,5 @@ +4 5 2 +0 2 2 2 2 +0 2 2 2 2 +1 1 2 2 2 +1 1 0 0 0 diff --git a/uts/uts_2017_sum_py/5/robot.in b/uts/uts_2017_sum_py/5/robot.in new file mode 100644 index 0000000..edda2db --- /dev/null +++ b/uts/uts_2017_sum_py/5/robot.in @@ -0,0 +1 @@ +RSSSSLSLSSLS \ No newline at end of file diff --git a/uts/uts_2k17_march_py/DER/A b/uts/uts_2k17_march_py/DER/A new file mode 100755 index 0000000..202ea11 Binary files /dev/null and b/uts/uts_2k17_march_py/DER/A differ diff --git a/uts/uts_2k17_march_py/DER/A.cpp b/uts/uts_2k17_march_py/DER/A.cpp new file mode 100644 index 0000000..0b261b0 --- /dev/null +++ b/uts/uts_2k17_march_py/DER/A.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +using namespace std; +#define MAXN 100007 + +int a[MAXN], tree[4 * MAXN], upd[4 * MAXN], n; + +void build_tree(int v, int tl, int tr) +{ + if(tl == tr) tree[v] = a[tl]; + else + { + int tm = (tl + tr) >> 1; + build_tree(v + v, tl, tm); + build_tree(v + v + 1, tm + 1, tr); + tree[v] = tree[v + v] + tree[v + v + 1]; + } +} + +int query_tree(int v, int tl, int tr, int l, int r) +{ + if(l > r) return 0; + if(upd[v] != -1) return upd[v] * (r - l + 1); + if(l == tl && r == tr) return tree[v]; + int tm = (tl + tr) >> 1; + return query_tree(v + v, tl, tm, l, min(r, tm)) + query_tree(v + v + 1, tm + 1, tr, max(l, tm + 1), r); +} + +void update_tree(int v, int tl, int tr, int l, int r, int color) +{ + if(l > r) return; + if(l == tl && tr == r) + { + upd[v] = color; + tree[v] = color * (r - l + 1); + } + else + { + upd[v] = -1; + int tm = (tl + tr) >> 1; + update_tree(v + v, tl, tm, l, min(r, tm), color); + update_tree(v + v + 1, tm + 1, tr, max(l, tm + 1), r, color); + tree[v] = tree[v + v] + tree[v + v + 1]; + } +} + +int main() +{ + ifstream cin("sum.in"); + ofstream cout("sum.out"); + int k; + cin >> n >> k; + for(int i = 0; i < 4 * MAXN; i++) upd[i] = -1; //Изначально все отрезки(вершины) не обновлены + build_tree(1, 0, n-1); + int q, x, l, r; + char type; + scanf("%d", &q); + for(int i = 0; i < k; i++) + { + cin >> type; + cin >> l; + cin >> r; + if(type == 'Q') + { + printf("%d\n", query_tree(1, 0, n - 1, l, r)); + } + else if(type == 'A') + { + update_tree(1, 0, n - 1, l, l, r); + } + } + + return 0; +} diff --git a/uts/uts_2k17_march_py/DER/A.py b/uts/uts_2k17_march_py/DER/A.py new file mode 100644 index 0000000..fec9570 --- /dev/null +++ b/uts/uts_2k17_march_py/DER/A.py @@ -0,0 +1,42 @@ +import sys +problem_name = str('sum') +sys.stdin = open(problem_name + ".in", "r") +#sys.stdout = open(problem_name+".out", "w") + +def deld(a): + left = len(a) // 2 + right = len(a) // 2 + len(a) % 2 + print(0, ' ', left, ' ', right, ' ', left+right) + b = [a[i] for i in range(left)] + c = [a[i] for i in range(left, left+right)] + return b, c + +def build(a, fab): + if len(a) <= 1: + return + left, right = deld(a) + fab.append([0]) + fab.append([0]) + build(left, fab[0]) + build(right, fab[1]) + +def build_linkers(a, fab): + + +n, k = list(map(int, input().split())) +mas = [[0] for i in range(n)] +fab = [] +build(mas, fab) +query = [] +for i in range(k-1): + s = input().split() + s[1] = int(s[1])-1 + s[2] = int(s[2]) + if s[0] == 'A': + mas[s[1]] = [s[2]] + else: + query.append(s) + +print(query) +print(mas) +print(fab) \ No newline at end of file diff --git a/uts/uts_2k17_march_py/DER/sum.in b/uts/uts_2k17_march_py/DER/sum.in new file mode 100644 index 0000000..f38ae92 --- /dev/null +++ b/uts/uts_2k17_march_py/DER/sum.in @@ -0,0 +1,10 @@ +5 9 +A 2 2 +A 3 1 +A 4 2 +Q 1 1 +Q 2 2 +Q 3 3 +Q 4 4 +Q 5 5 +Q 1 5 diff --git a/uts/uts_2k17_march_py/Dun/A.py b/uts/uts_2k17_march_py/Dun/A.py new file mode 100644 index 0000000..a6328f2 --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/A.py @@ -0,0 +1,9 @@ +import sys +from math import factorial +problem_name = str('combs') +sys.stdin = open(problem_name + ".in", "r") +#sys.stdout = open(problem_name+".out", "w") +n, k = list(map(int, input().split())) +print(int(factorial(n)/(factorial(k)*factorial(n-k)))) +f = open('safdsf') +f.close() \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/B.py b/uts/uts_2k17_march_py/Dun/B.py new file mode 100644 index 0000000..41780ac --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/B.py @@ -0,0 +1,14 @@ +import sys +problem_name = str('slalom') +sys.stdin = open(problem_name + ".in", "r") +sys.stdout = open(problem_name+".out", "w") + +n= int(input()) +a = [] +for i in range(n): + a.append(list(map(int, input().split()))) +count=0 +for i in reversed(range(len(a)-1)): + for j in range(len(a[i])): + a[i][j] = a[i][j] + max(a[i+1][j], a[i+1][j+1]) +print(a[0][0]) \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/C.py b/uts/uts_2k17_march_py/Dun/C.py new file mode 100644 index 0000000..d05b8b3 --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/C.py @@ -0,0 +1,5 @@ +import sys +problem_name = str('mushroom') +sys.stdin = open(problem_name + ".in", "r") +sys.stdout = open(problem_name+".out", "w") + diff --git a/uts/uts_2k17_march_py/Dun/D.py b/uts/uts_2k17_march_py/Dun/D.py new file mode 100644 index 0000000..724851e --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/D.py @@ -0,0 +1,18 @@ +import sys +problem_name = str('field') +sys.stdin = open(problem_name + ".in", "r") +sys.stdout = open(problem_name+".out", "w") + +n, m = map(int, input().split()) +a = [] +b = [[10**9] * n for i in range(m)] +for i in range(m): + a.append(list(map(int, input().split()))) +b[0][0] = 0 +for i in range(m): + for j in range(n): + if i - 1 >= 0: + b[i][j] = abs(a[i][j] - a[i - 1][j]) + b[i - 1][j] + if j - 1 >= 0: + b[i][j] = min(b[i][j], b[i][j - 1] + abs(a[i][j] - a[i][j - 1])) +print(b[m - 1][n - 1]) \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/E.py b/uts/uts_2k17_march_py/Dun/E.py new file mode 100644 index 0000000..adfc0b2 --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/E.py @@ -0,0 +1,22 @@ +import sys +problem_name = str('goat') +sys.stdin = open(problem_name + ".in", "r") +#sys.stdout = open(problem_name+".out", "w") + +m, n, k = map(int, input(). split()) +T = [[False]*(n+1) for i in range(m+1)] +for i in range(k): + n, y = map(int, input().split()) + T[n - 1][y - 1] = True +C = [[0]*(n+1) for i in range(m+1)] +C[1][1] = 1 +dead = 0 +for i in range(1, m+1): + for j in range(1, n+1): + if i == 1 and j == 1: + comb = 1 + else: + comb = C[i-1][j] + C[i][j-1] + if T[i][j]: + dead += comb + comb = 0 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/H.py b/uts/uts_2k17_march_py/Dun/H.py new file mode 100644 index 0000000..feed6cb --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/H.py @@ -0,0 +1,9 @@ +import sys +import re +problem_name = str('patterns') +sys.stdin = open(problem_name + ".in", "r") +sys.stdout = open(problem_name+".out", "w") +if re.compile(input().replace('*', '.*').replace('?', '.')).match(input()) != None: + print('YES') +else: + print('NO') diff --git a/uts/uts_2k17_march_py/Dun/combs.in b/uts/uts_2k17_march_py/Dun/combs.in new file mode 100644 index 0000000..316bd14 --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/combs.in @@ -0,0 +1 @@ +3 2 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/field.in b/uts/uts_2k17_march_py/Dun/field.in new file mode 100644 index 0000000..0cc504d --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/field.in @@ -0,0 +1,3 @@ +4 2 +1 2 3 5 +3 8 4 7 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/goat.in b/uts/uts_2k17_march_py/Dun/goat.in new file mode 100644 index 0000000..228729e --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/goat.in @@ -0,0 +1,5 @@ +2 2 1 +1 2 +2 2 2 +1 2 +2 1 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/mushroom.in b/uts/uts_2k17_march_py/Dun/mushroom.in new file mode 100644 index 0000000..d8d13d7 --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/mushroom.in @@ -0,0 +1,6 @@ +4 4 3 2 +1 4 +2 3 +4 3 +2 2 +3 4 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/patterns.in b/uts/uts_2k17_march_py/Dun/patterns.in new file mode 100644 index 0000000..bdf2013 --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/patterns.in @@ -0,0 +1,2 @@ +k?t?n +kitten \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Dun/slalom.in b/uts/uts_2k17_march_py/Dun/slalom.in new file mode 100644 index 0000000..2b193af --- /dev/null +++ b/uts/uts_2k17_march_py/Dun/slalom.in @@ -0,0 +1,5 @@ +4 +1 +4 3 +5 6 7 +8 9 0 9 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Str/A.py b/uts/uts_2k17_march_py/Str/A.py new file mode 100644 index 0000000..e73844a --- /dev/null +++ b/uts/uts_2k17_march_py/Str/A.py @@ -0,0 +1,55 @@ +import sys + +ID = "strings" +sys.stdin = open(ID + ".in", "r") + + +# sys.stdout = open(ID + ".out", "w") + +def KMP(s, x): + S = x + '#' + s # Большая строка + print('S = ' + S) + P = [0] * len(S) # Префикс-функция + m = len(x) # Длина подстроки + # print(template) + found = False + for i in range(1, len(S)): + # Префикс-функция для предыдущего + # символа + # i - индекс в строке + # j - индекс в префиксе (подстроке) + print() + print('Символ: ' + S[:i] + "[" + S[i] + "]" + S[(i + 1):], end=' ') + j = P[i - 1] # незачем смотреть всю строку, можно посмотреть со сдвига прошлой подстроки + print('P[' + str(i - 1) + '] = ' + str(j), end=' ') + while j > 0 and S[j] != S[i]: + print('j: ' + str(j - 1) + + ' -> P[' + str(j - 1) + '] = ' + + str(P[j - 1]), end=' ') + j = P[j - 1] + if S[j] == S[i]: + j += 1 + print(' S[' + str(j) + '] == S[' + str(i) + '] == ' + str(S[i]) + ' ' + + 'P[' + str(i) + '] = ' + str(j), end=' ') + P[i] = j + # Если видим длину подстроки + # то мы её нашли + if j == m: + if found: + print(' ', end='') + found = True + print(i - m * 2 + 1) + if not found: + print('none') + print(P) + + +while True: + try: + s = input() + t = input() + except EOFError: + break + KMP(s, t) + +sys.stdout.close() diff --git a/uts/uts_2k17_march_py/Str/B.py b/uts/uts_2k17_march_py/Str/B.py new file mode 100644 index 0000000..9ef5a56 --- /dev/null +++ b/uts/uts_2k17_march_py/Str/B.py @@ -0,0 +1,7 @@ +import sys +import collections +problem_name = str('substr') +sys.stdin = open(problem_name + ".in", "r") +sys.stdout = open(problem_name+".out", "w") + +print(collections.Counter(input()).most_common()[0][0]) \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Str/C.py b/uts/uts_2k17_march_py/Str/C.py new file mode 100644 index 0000000..48d839f --- /dev/null +++ b/uts/uts_2k17_march_py/Str/C.py @@ -0,0 +1,5 @@ +import sys +problem_name = str('double') +sys.stdin = open(problem_name + ".in", "r") +#sys.stdout = open(problem_name+".out", "w") + diff --git a/uts/uts_2k17_march_py/Str/D.py b/uts/uts_2k17_march_py/Str/D.py new file mode 100644 index 0000000..9a178fe --- /dev/null +++ b/uts/uts_2k17_march_py/Str/D.py @@ -0,0 +1,4 @@ +import sys +problem_name = str('genstr') +sys.stdin = open(problem_name + ".in", "r") +sys.stdout = open(problem_name+".out", "w") diff --git a/uts/uts_2k17_march_py/Str/double.in b/uts/uts_2k17_march_py/Str/double.in new file mode 100644 index 0000000..63d7f6c --- /dev/null +++ b/uts/uts_2k17_march_py/Str/double.in @@ -0,0 +1,2 @@ +aaaaaab +5 \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Str/strings.in b/uts/uts_2k17_march_py/Str/strings.in new file mode 100644 index 0000000..f55762a --- /dev/null +++ b/uts/uts_2k17_march_py/Str/strings.in @@ -0,0 +1,2 @@ +abbabas +aba \ No newline at end of file diff --git a/uts/uts_2k17_march_py/Str/substr.in b/uts/uts_2k17_march_py/Str/substr.in new file mode 100644 index 0000000..f2ba8f8 --- /dev/null +++ b/uts/uts_2k17_march_py/Str/substr.in @@ -0,0 +1 @@ +abc \ No newline at end of file