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

πŸš€ Grow Your Instagram Fast – Get Real Followers, Likes & Views Starting at Just β‚Ή5!

😎 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()

Q2 Solutions -


If we've helped you, please support us with a donation. β€οΈπŸ™


Q3 Solutions -



Q4 Solutions





Comments

Popular posts from this blog

Get All Coding Solutions

Codeforces Contest Round 1025 (Div.2) | All Questions Solutions – FREE! | 17 May 2025