Since the explanations on the official website are sufficiently clear, I will post only the code solutions without any conceptual origination.
A: Second Hands
import sys
sys.stdin = open('second_hands_input.txt', 'r')
C = int(sys.stdin.readline())
res =[]
for i in range(C):
arr = [int(x) for x in sys.stdin.readline().split()]
N, T = arr[0], arr[1]
S = [int(x) for x in sys.stdin.readline().split()]
if N > (T*2):
res.append(False)
continue
more_than_twice = False
hist = {}
for el in S:
if el in hist:
hist[el] += 1
else:
hist[el] = 1
if hist[el] > 2:
more_than_twice = True
break
res.append(not(more_than_twice))
print(res)
sys.stdout = open('output.txt', 'w')
for i in range(C):
if res[i]:
sys.stdout.write(f'Case #{i+1}: YES')
if i<C-1:
sys.stdout.write('\n')
else:
sys.stdout.write(f'Case #{i+1}: NO')
if i<C-1:
sys.stdout.write('\n')
B1: Second Friend
import sys
sys.stdin = open('second_friend_input.txt', 'r')
sys.stdout = open('output.txt', 'w')
N = int(sys.stdin.readline())
for n in range(N):
sudo = [int(x) for x in sys .stdin.readline().split()]
R, C = sudo[0], sudo[1]
tree_present = False
for r in range(R):
arr = list(sys.stdin.readline())
for c in range(C):
if arr[c] == '^':
tree_present = True
break
if tree_present:
if (R<2) or (C<2):
sys.stdout.write(f'Case #{n+1}: Impossible')
sys.stdout.write('\n')
else:
sys.stdout.write(f'Case #{n+1}: Possible')
for i in range(R):
sys.stdout.write('\n')
for i in range(C):
sys.stdout.write('^')
sys.stdout.write('\n')
else:
sys.stdout.write(f'Case #{n+1}: Possible')
for i in range(R):
sys.stdout.write('\n')
for i in range(C):
sys.stdout.write('.')
sys.stdout.write('\n')
C1: Second Meaning
import sys
sys.stdin = open('second_meaning_input.txt', 'r')
sys.stdout = open('output_final.txt', 'w')
T = int(sys.stdin.readline())
for t in range(T):
res = []
N = int(sys.stdin.readline())
c = sys.stdin.readline()
sys.stdout.write(f'Case #{t+1}:')
sys.stdout.write('\n')
first_code = c[0]
if first_code == '.':
for n in range(N-1):
c = '-' + c
sys.stdout.write(f'{c}')
else:
for n in range(N-1):
c = '.' + c
sys.stdout.write(f'{c}')
Remarks
These were the questions I did for the qualification rounds. Will try to upload the other question solutions before the next round commences for practice sake.
Top comments (0)