結果
問題 | No.606 カラフルタイル |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:32:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 227 ms / 2,000 ms |
コード長 | 1,141 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,344 KB |
実行使用メモリ | 120,828 KB |
最終ジャッジ日時 | 2025-03-20 20:33:35 |
合計ジャッジ時間 | 4,542 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]); ptr +=1 K = int(input[ptr]); ptr +=1 Q = int(input[ptr]); ptr +=1 row_ts = [0] * (N + 1) # 1-based row_color = [1] * (N + 1) col_ts = [0] * (N + 1) col_color = [1] * (N + 1) for t in range(1, Q + 1): A = input[ptr]; ptr +=1 B = int(input[ptr]); ptr +=1 C = int(input[ptr]); ptr +=1 if A == 'R': row_ts[B] = t row_color[B] = C else: col_ts[B] = t col_color[B] = C sorted_row = sorted(row_ts[1:N+1]) sorted_col = sorted(col_ts[1:N+1]) counts = [0] * (K + 1) # Process rows for i in range(1, N+1): ts = row_ts[i] c = row_color[i] cnt = bisect.bisect_left(sorted_col, ts) counts[c] += cnt # Process columns for j in range(1, N+1): ts = col_ts[j] c = col_color[j] cnt = bisect.bisect_right(sorted_row, ts) counts[c] += cnt for k in range(1, K+1): print(counts[k]) if __name__ == "__main__": main()