結果

問題 No.606 カラフルタイル
ユーザー LyricalMaestro
提出日時 2024-02-09 00:49:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 96,804 KB
最終ジャッジ日時 2024-09-28 12:55:57
合計ジャッジ時間 4,837 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/606




def main():
    N, K, Q = map(int, input().split())
    abc = []
    for _ in range(Q):
        a, b, c  = input().split()
        abc.append((a, int(b) - 1, int(c) - 1))
    
    answers = [0] * K
    answers[0] = N * N
    row_colors = [-1] * N
    col_colors = [-1] * N
    rows = 0
    cols = 0

    for i in reversed(range(Q)):
        a, b, c = abc[i]
        if a == "R":
            if row_colors[b] == -1:
                row_colors[b] = c
                answers[c] += N - cols
                answers[0] -= N - cols
                rows += 1
        else:
            if col_colors[b] == -1:
                col_colors[b] = c
                answers[c] += N - rows
                answers[0] -= N - rows
                cols += 1
    
    for answer in answers:
        print(answer)




if __name__ == "__main__":
    main()
0