結果

問題 No.606 カラフルタイル
ユーザー kuwakuwa
提出日時 2017-12-10 17:51:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 67,844 KB
実行使用メモリ 5,228 KB
最終ジャッジ日時 2023-08-20 09:54:22
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 AC 144 ms
5,152 KB
testcase_18 AC 17 ms
4,400 KB
testcase_19 AC 16 ms
4,384 KB
testcase_20 AC 147 ms
5,228 KB
testcase_21 AC 18 ms
4,636 KB
testcase_22 AC 18 ms
4,676 KB
testcase_23 AC 36 ms
4,616 KB
testcase_24 AC 106 ms
4,960 KB
testcase_25 AC 145 ms
5,068 KB
testcase_26 AC 146 ms
5,180 KB
testcase_27 AC 143 ms
5,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

using ll = long long;

int N, K, Q;
char a[100000];
int b[100000], c[100000];

char vr[100000], vc[100000];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K >> Q;
    for (int j = 0; j < Q; ++j) {
        cin >> a[j] >> b[j] >> c[j];
        --b[j]; --c[j];
    }

    ll ans[100000], s = 0;
    fill(ans, ans+K, 0);
    int ir = N, ic = N;
    for (int j = Q-1; j >= 0; --j) {
        if (a[j] == 'R' && !vr[b[j]]) {
            s += ir;
            ans[c[j]] += ir;
            vr[b[j]] = true;
            --ic;
        }
        if (a[j] == 'C' && !vc[b[j]]) {
            s += ic;
            ans[c[j]] += ic;
            vc[b[j]] = true;
            --ir;
        }
    }
    ans[0] += (ll)N*N - s;
    for (int j = 0; j < K; ++j) {
        cout << ans[j] << endl;
    }
    return 0;
}
0