AtCoder Regular Contest 197 (Div. 2)β All Questions Solution FREE π»π₯
AtCoder Regular Contest 197 (Div. 2) β All Questions Solution FREE π»π₯
Myntra is Hiring Software Development Intern - Batch of 2026 - Open Campus- Apply Now
πScroll down to get all solutions!π
π¨ Note: The Code of Conduct has been updated β make sure to follow the latest rules!!
π₯ Get All Contest Solutions!
Want access to all solutions from this contest? Just follow these simple steps:
β
Step 1: Subscribe to our YouTube channel
πΈ Step 2: Take a screenshot of your subscription
π¬ Step 3: Send the screenshot along with your Telegram name (as it appears in Telegram)
π Step 4: Get admin access to our Official Telegram Channel and receive all the solutions!
π’ Join now and never miss any updates!
π https://t.me/+0dnF7vnXJ8lkOGFl
π‘ All solutions will be uploaded, so make sure to subscribe and join our Telegram channel!
π Donβt miss this opportunity to learn, compete, and grow as a coder! Letβs crack Starters 184 together! π₯π»
πScroll down to get all solutions!π
#Promotion
π DEMO FOR ALL SERVICES AVAILABLE β START NOW
Place Your First Order & Watch the Magic Begin in Just 5β10 Minutes!
β Instant Delivery | β 100% Money-Back Guarantee
β‘ DEMO SERVICES
1οΈβ£ 500 Followers β Just βΉ80 π€
2οΈβ£ 500 Likes β Only βΉ5 π
3οΈβ£ 1K Reels Views β Just βΉ5 π
π¦ CHEAPEST GUARANTEED INSTAGRAM FOLLOWERS
π Starts in 5 -10 Minutes π₯π Complete time - 30π₯
1K Followers β βΉ150
2K Followers β βΉ300
3K Followers β βΉ450
5K + 1K FREE β βΉ650β 900β
10K + 1K FREE β βΉ1300β 1800β
β No Drops | β Real Followers | β Trusted Quality
β€ INSTAGRAM GUARANTEED LIKES
π Starts in 1 - 5 Minutes π₯π Complete time - 5 π₯
1K Likes β βΉ10
5K Likes β βΉ40 β 50β
10K Likes β βΉ80β 100β
20K+2K Likes β βΉ160β 220β
30K+3K Likes β βΉ250β 330β
40K+4K Likes β βΉ340β 440β
50K+10k Likes β βΉ450β 600β
π₯ INSTAGRAM REELS VIEWS
π Starts in 1 - 3 Minutes π₯π Complete time - 5 π₯
1K Views β βΉ5
5K+1K Views β βΉ20β 30β
10K+2K Views β βΉ30β 60β
20K+4K Views β βΉ60β 120β
50K+5K Views β βΉ180β 280β
100K+10K Views β βΉ300β 500β
500K+10K Views β βΉ600β 1500β
π² CONTACT NOW TO PLACE YOUR 1ST ORDER
Order Now : Contact On WhatsApp
Service Proof : Instagram Id
β¨ Be Viral. Be Famous. Be YOU β With the Power of Social Growth!
Please Subscribe Our YouTube Channel
NOTE :- Donβt copy the full code β use the logic.
We're not responsible for plagiarism issues.
Thank you!
Q1 Solutions -
import sys
def main():
input = sys.stdin.read().split()
idx = 0
T = int(input[idx])
idx += 1
results = []
for _ in range(T):
H = int(input[idx])
W = int(input[idx+1])
idx +=2
S = input[idx]
idx +=1
L = H + W -2
prefix_D = [0]*(L+1)
prefix_Q = [0]*(L+1)
for i in range(L):
prefix_D[i+1] = prefix_D[i] + (1 if S[i] == 'D' else 0)
prefix_Q[i+1] = prefix_Q[i] + (1 if S[i] == '?' else 0)
total_D = prefix_D[L]
total_Q = prefix_Q[L]
ans = 0
for k in range(L+1):
h_min = max(1, (k +2) - W)
h_max = min(H, k +1)
if h_min > h_max:
continue
fixed_D_first = prefix_D[k]
q_first = prefix_Q[k]
remaining_D_fixed = total_D - fixed_D_first
remaining_Q_rem = total_Q - q_first
h_low1 = fixed_D_first +1
h_high1 = fixed_D_first + q_first +1
h_low2 = H - (remaining_D_fixed + remaining_Q_rem)
h_high2 = H - remaining_D_fixed
h_low = max(h_low1, h_low2)
h_high = min(h_high1, h_high2)
h_low_total = max(h_low, h_min)
h_high_total = min(h_high, h_max)
if h_low_total > h_high_total:
continue
ans += h_high_total - h_low_total +1
results.append(ans)
sys.stdout.write('\n'.join(map(str, results)) + '\n')
if __name__ == '__main__':
main()
Comments
Post a Comment