結果
問題 | 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 bisectdef main():import sysinput = sys.stdin.read().split()ptr = 0N = int(input[ptr]); ptr +=1K = int(input[ptr]); ptr +=1Q = int(input[ptr]); ptr +=1row_ts = [0] * (N + 1) # 1-basedrow_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 +=1B = int(input[ptr]); ptr +=1C = int(input[ptr]); ptr +=1if A == 'R':row_ts[B] = trow_color[B] = Celse:col_ts[B] = tcol_color[B] = Csorted_row = sorted(row_ts[1:N+1])sorted_col = sorted(col_ts[1:N+1])counts = [0] * (K + 1)# Process rowsfor 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 columnsfor j in range(1, N+1):ts = col_ts[j]c = col_color[j]cnt = bisect.bisect_right(sorted_row, ts)counts[c] += cntfor k in range(1, K+1):print(counts[k])if __name__ == "__main__":main()