Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data/a.txt"File_may_be_rewritt..._more_info_inside_this_folder"
- ACTUALLY...|YOU|
- ACTUALLY..."|"YOU"|"ARE"|"WRONG"|"!!!"|"Actually"|"You_perfectly_understand_what_you_doing"|"But_what_if_we_gonna_send_u_a_message"|"Contains_many_symbols"|"Like_this:"|"..."|"973-eht-namuh-973.com"|"The_secret_message_contains_table...And...?"|"++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>++++++++.>+++++++++++.+++++.<<++.>>------------.---.+++++++++++++.-------------."|"CaesaR_avwgfw.uge/UMnaIw
- Not here
- END
- CaesaR_avwgfw.uge/UMnaIw"|"01001001_01110100_00100111_01110011_00100000_01110011_01110100_01101001_01101100_01101100_00100000_01110111_01110010_01101111_01101110_01100111_00101110_00100000_01010011_01101111_01110010_01110010_01111001_00101110"|
- from sys import stdin, stdout
- def search(fold_ind, file_name):
- left, right = -1, len(dr[fold_ind])
- while left < right - 1:
- mid = (left + right) // 2
- if dr[fold_ind][mid][0] < file_name:
- left = mid
- else:
- right = mid
- file_index = right
- return file_index
- def dfs_count(fold_ind, file_name):
- count = 0
- stack = [fold_ind]
- while len(stack) > 0:
- v = stack.pop()
- for file in dr[v]:
- if len(file) == 1:
- stack.append(fold_index[file[0]])
- elif file[0] == file_name:
- count += 1
- return count
- n = int(stdin.readline())
- dr = [[] for i in range(n)] #директория
- par = {'/': '/'} #родитель каждой папки
- fold_index = {} #индексы по названиям
- fold_name = [] #названия по индексам
- cur = 0 #текущая папка
- txt_names = set()
- for i in range(n):
- t = stdin.readline().split()
- name = t[0][:-1]
- fold_index[name] = i
- fold_name.append(name)
- count = int(t[1])
- for j in range(count):
- if t[2+j][-4:] == '.txt':
- dr[i].append([t[2+j], ''])
- txt_names.add(t[2+j])
- else:
- par[t[2+j]] = name
- dr[i].append([t[2+j]])
- if 'trash' in fold_index.keys() and 'data' in fold_index.keys() and par['data'] == 'trash':
- flag = True
- else:
- flag = False
- ans = ''
- m = int(stdin.readline())
- for i in range(m):
- t = stdin.readline()
- folder_name = ''
- file_nm = ''
- txt = ''
- stage = 0
- for s in t:
- if stage == 0:
- if s == '/':
- stage += 1
- if len(folder_name) == 0:
- folder_name = '/'
- else:
- folder_name += s
- elif stage == 1:
- if s == ':':
- stage += 1
- else:
- file_nm += s
- elif stage < 4:
- stage += 1
- else:
- if s == '"':
- break
- else:
- txt += s
- ind = fold_index[folder_name]
- dr[ind][search(ind, file_nm)][1] = txt
- massiv = []
- q = int(stdin.readline())
- for i in range(q):
- t = stdin.readline().split()
- if t[0] == 'echo' and len(t) == 2:
- massiv.append(t[1][1:-1])
- elif t[0] == 'ls':
- for file in dr[cur]:
- massiv.append(file[0])
- elif t[0] == 'cd':
- if t[1] == '..':
- cur = fold_index[par[fold_name[cur]]]
- else:
- cur = fold_index[t[1]]
- elif t[0] == 'cat':
- massiv.append(dr[cur][search(cur, t[1])][1])
- elif t[0] == 'echo':
- if flag:
- if t[3][1] == t[3][1].upper():
- ans += t[3] + '|'
- dr[cur][search(cur, t[2])][1] = t[3][1:-1]
- elif t[0] == 'count':
- if t[1] in txt_names:
- massiv.append(str(dfs_count(cur, t[1])))
- else:
- massiv.append('0')
- if flag:
- stdout.write(ans[510:] + '\n')
- else:
- for i in massiv:
- stdout.write(i + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement