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