BẢNG KÍ TỰ

View as PDF

Submit solution

Points: 100.00 (partial)
Time limit: 1.0s
Memory limit: 512M
Input: stdin
Output: stdout

Problem type
Allowed languages
C++, Pascal, Python

In case the statement didn't load correctly, you can download the statement here: Statement


Comments

Please read the guidelines before commenting.



  • -1
    maiducninh   commented on April 5, 2025, 8:33 p.m. edit 2

    def solve(): m, n, k = map(int, input().split()) board = [input() for _ in range(m)] max_area = 0

    for r1 in range(m):
        for c1 in range(n):
            for r2 in range(r1, m):
                for c2 in range(c1, n):
                    sub_board = [row[c1:c2+1] for row in board[r1:r2+1]]
                    rows = len(sub_board)
                    cols = len(sub_board[0]) if rows > 0 else 0
                    if rows == 0 or cols == 0:
                        continue
    
                    a_count = 0
                    b_count = 0
                    for row in sub_board:
                        a_count += row.count('A')
                        b_count += row.count('B')
    
                    if abs(a_count - b_count) <= k:
                        max_area = max(max_area, rows * cols)
    
    print(max_area)
    

    t = int(input()) xuống dòng for _ in range(t): xuống dòng tab solve()


  • -1
    maiducninh   commented on April 5, 2025, 8:32 p.m.

    Tui có code python đúng 5/20 nè


  • 1
    KVMB23A_67   commented on Aug. 18, 2024, 9:10 p.m.

    mik có ý tưởng nè: dùng prefix sum để tính độ chênh lệnh, chỉ xét các ô lớn hơn ô lớn nhất hiện tại, liên tục cập nhật ô lớn nhất hiện tại nhé


  • 0
    SK24_A433   commented on July 16, 2024, 4:36 p.m.

    :)


  • 0
    DucKien2014   commented on June 28, 2024, 10:09 p.m.

    Ai cho tui code đc ko?


  • 0
    HDG_12   commented on June 20, 2024, 3:09 p.m.

    khó thế