Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oblemset into master
  • Loading branch information
seikhchilli committed May 3, 2024
2 parents 1d70201 + bbb3466 commit 9ba28c0
Show file tree
Hide file tree
Showing 17 changed files with 406 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 1933A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
a = list(map(int, input().split()))

tot = 0
for aa in a:
tot+=abs(aa)

outs.append(tot)

for out in outs:
print(out)
28 changes: 28 additions & 0 deletions 1933B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
a = list(map(int, input().split()))

rems = {0:0, 1:0, 2:0}
tot = 0
for aa in a:
tot+=aa
rems[aa%3]+=1

if tot%3==0:
out = 0
elif tot%3==1:
if rems[1]>0:
out = 1
else:
out = 2
else:
out = 1

outs.append(out)

for out in outs:
print(out)
23 changes: 23 additions & 0 deletions 1933C.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import math

t = int(input())
outs = []


for tt in range(t):
a, b, l = map(int, input().split())

x_m = math.ceil(math.log(l)/math.log(a))
y_m = math.ceil(math.log(l)/math.log(b))

ks = set()
for x in range(x_m+1):
for y in range(y_m+1):
k = l/(a**x)/(b**y)
if k>0 and math.floor(k)==math.ceil(k):
ks.add(math.floor(k))

outs.append(len(ks))

for out in outs:
print(out)
24 changes: 24 additions & 0 deletions 1933D.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
t = int(input())
outs = []

for tt in range(t):
n = int(input())
a = list(map(int, input().split()))

a.sort()
if a[0]!=a[1]:
out = 'YES'
else:
if n==2:
out = 'NO'
else:
out = False
for aa in a[2:]:
if aa%a[0]!=0:
out = True
break
out = 'YES' if out else 'NO'
outs.append(out)

for out in outs:
print(out)
28 changes: 28 additions & 0 deletions 1948B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
a = list(map(int, input().split()))

last = a[-1]

pos = True
for aa in a[:-1][::-1]:

if aa>last:
if aa>=10 and aa//10<=aa%10 and aa%10<=last:
last = aa//10
else:
pos = False
break
else:
last = aa

out = 'YES' if pos else 'NO'
outs.append(out)


for out in outs:
print(out)
24 changes: 24 additions & 0 deletions 1957A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
t = int(input())
outs = []

for _ in range(t):
n = int(input())
a = list(map(int, input().split()))

e = {}
for aa in a:
if aa in e.keys():
e[aa]+=1
else:
e[aa]=1

tot = 0
for k, v in e.items():
tot += v//3

out = [tot]
outs.append(out)


for out in outs:
print(*out)
24 changes: 24 additions & 0 deletions 1957B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
t = int(input())
outs = []


for _ in range(t):
n, k = map(int, input().split())

out = [0]*n

bits = k.bit_length()
num = 2**(bits-1)-1
out[0] = num

rem = k-num
if n==1:
out[0]+=rem
else:
out[1] = rem

outs.append(out)


for out in outs:
print(*out)
25 changes: 25 additions & 0 deletions 1966A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
t = int(input())
outs = []


for tt in range(t):
n, k = map(int, input().split())
c = list(map(int, input().split()))

pos = False
counts = {}
for cc in c:
if cc in counts.keys():
counts[cc]+=1
else:
counts[cc]=1

if counts[cc]>=k:
pos=True

out = k-1 if pos else n
outs.append(out)


for out in outs:
print(out)
46 changes: 46 additions & 0 deletions 1966B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
t = int(input())
outs = []


for tt in range(t):
n, m = map(int, input().split())
a = [None]*n
for i in range(n):
r = input()
a[i] = r

b = {'x':{}, 'y':{}}
w = {'x':{}, 'y':{}}

b['x']['min'], b['x']['max'] = 550, -1
b['y']['min'], b['y']['max'] = 550, -1
w['x']['min'], w['x']['max'] = 550, -1
w['y']['min'], w['y']['max'] = 550, -1

pos = False
for i in range(n):
for j in range(m):
if a[i][j]=='B':
b['x']['min']=min(b['x']['min'], i)
b['x']['max']=max(b['x']['max'], i)
b['y']['min']=min(b['y']['min'], j)
b['y']['max']=max(b['y']['max'], j)
else:
w['x']['min']=min(w['x']['min'], i)
w['x']['max']=max(w['x']['max'], i)
w['y']['min']=min(w['y']['min'], j)
w['y']['max']=max(w['y']['max'], j)

if b['x']['min']==0 and b['x']['max']==n-1 and b['y']['min']==0 and b['y']['max']==m-1:
pos = True
break
elif w['x']['min']==0 and w['x']['max']==n-1 and w['y']['min']==0 and w['y']['max']==m-1:
pos = True
break

out = 'YES' if pos else 'NO'
outs.append(out)


for out in outs:
print(out)
23 changes: 23 additions & 0 deletions 1966C.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
a = list(map(int, input().split()))

a = [0] + sorted(list(set(a)))

win = True
for i in range(len(a)-3, -1, -1):
if a[i+1]-a[i]==1:
win = not win
else:
win = True

out = 'Alice' if win else 'Bob'
outs.append(out)


for out in outs:
print(out)
19 changes: 19 additions & 0 deletions 1969A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
p = list(map(int, input().split()))

out = 3
for i in range(1, n+1):
if p[p[i-1]-1]==i:
out=2
break

outs.append(out)


for out in outs:
print(out)
26 changes: 26 additions & 0 deletions 1969B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
t = int(input())
outs = []


for tt in range(t):
s = input()
n = len(s)

lst = -1
for i in range(n):
if s[i]=='0':
lst=i
else:
break

tot = 0
for i in range(lst+1, n):
if s[i]=='0':
tot+=i-lst
lst+=1

outs.append(tot)


for out in outs:
print(out)
26 changes: 26 additions & 0 deletions 1972A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

tot = 0
a_i, b_i = 0, 0

while b_i<n:
if a[a_i]>b[b_i]:
tot+=1
b_i+=1
else:
a_i+=1
b_i+=1

outs.append(tot)


for out in outs:
print(out)

20 changes: 20 additions & 0 deletions 1972B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
s = input()

sum_=0
for ss in s:
sum_ = sum_ ^ (int(ss=='U'))

out = 'YES' if sum_!=0 else 'NO'

outs.append(out)


for out in outs:
print(out)

Loading

0 comments on commit 9ba28c0

Please sign in to comment.