結果

問題 No.606 カラフルタイル
ユーザー ふーらくたるふーらくたる
提出日時 2017-12-07 22:36:17
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 998 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 72,432 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 12:29:08
合計ジャッジ時間 5,269 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using int64 = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int64 N;
    int K, Q;
    cin >> N >> K >> Q;

    map<string, int> mp;
    mp["R"] = 0;
    mp["C"] = 1;

    const int maxq = 20000;
    const int maxn = 20000;
    const int maxk = 20000;

    static string A[maxq];
    static int B[maxq], C[maxq];

    static bool used[2][maxn];
    static int64 ans[maxk];
    for (int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i] >> C[i];
        B[i]--; C[i]--;
    }

    int64 cnt[2] = {0, 0};
    for (int i = Q - 1; i >= 0; i--) {
        int rc = mp[A[i]];
        if (used[rc][B[i]]) continue;
        
        used[rc][B[i]] = true;
        ans[C[i]] += N - cnt[rc ^ 1];
        cnt[rc]++;
    }

    int64 sum = 0;
    for (int i = 0; i < K; i++) {
        sum += ans[i];
    }
    ans[0] += N * N - sum;

    for (int i = 0; i < K; i++) {
        cout << ans[i] << '\n';
    }

    return 0;
}
0