結果

問題 No.606 カラフルタイル
ユーザー hiroakiehiroakie
提出日時 2017-12-18 22:55:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 62,072 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-05-09 12:01:11
合計ジャッジ時間 3,321 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 17 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 42 ms
5,376 KB
testcase_17 AC 195 ms
5,376 KB
testcase_18 AC 57 ms
5,376 KB
testcase_19 AC 55 ms
5,376 KB
testcase_20 AC 215 ms
5,632 KB
testcase_21 AC 79 ms
5,376 KB
testcase_22 AC 75 ms
5,376 KB
testcase_23 AC 92 ms
5,376 KB
testcase_24 AC 169 ms
5,504 KB
testcase_25 AC 199 ms
5,376 KB
testcase_26 AC 196 ms
5,760 KB
testcase_27 AC 199 ms
5,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 100000;
int n, k, q;
pair<int, int> r[N], c[N];
long long int ct[N];
int main() {
	cin >> n >> k >> q;
	for (int i = 0; i < n; i++) { r[i] = make_pair(-i*2-2, 0); c[i] = make_pair(-i*2-1, 0); }
	for (int i = 0; i < q; i++) {
		char v1; int v2, v3; cin >> v1 >> v2 >> v3;
		if (v1 == 'R')r[v2 - 1] = make_pair(i, v3-1);
		else c[v2 - 1] = make_pair(i, v3-1);
	}
	sort(r, r + n);
	sort(c, c + n);
	for (int i = 0; i < n; i++) {
		ct[r[i].second]+= lower_bound(c, c + n, r[i]) - c;
		ct[c[i].second] += lower_bound(r, r + n, c[i]) - r;
	}
	for (int i = 0; i < k; i++)cout << ct[i] << endl;
	return 0;
}
0