結果

問題 No.606 カラフルタイル
ユーザー kagasankagasan
提出日時 2019-10-08 17:11:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,277 bytes
コンパイル時間 1,863 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-24 21:10:27
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 40 ms
5,376 KB
testcase_17 AC 98 ms
10,496 KB
testcase_18 AC 82 ms
9,728 KB
testcase_19 AC 76 ms
9,088 KB
testcase_20 AC 111 ms
9,728 KB
testcase_21 AC 84 ms
8,832 KB
testcase_22 AC 81 ms
8,960 KB
testcase_23 AC 89 ms
8,064 KB
testcase_24 AC 95 ms
8,576 KB
testcase_25 AC 68 ms
5,760 KB
testcase_26 AC 105 ms
10,496 KB
testcase_27 AC 106 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
template<class T> bool find_from_set(set<T> &S, const T &t){
    return S.find(t) != S.end();
}

int main(){

    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll>ans(K + 1, 0);
    vector<char>A(Q);
    vector<ll>B(Q), C(Q);
    ans[1] = N * N;
    rep(i, Q)cin >> A[i] >> B[i] >> C[i];
    set<ll>C_set, R_set;
    rrep(i, Q){
        if(A[i] == 'C' && !find_from_set(C_set, B[i])){
            C_set.insert(B[i]);
            ll tmp = N - R_set.size();
            ans[1] -= tmp;
            ans[C[i]] += tmp;
        }
        if(A[i] == 'R' && !find_from_set(R_set, B[i])){
            R_set.insert(B[i]);
            ll tmp = N - C_set.size();
            ans[1] -= tmp;
            ans[C[i]] += tmp;
        }
    }
    rep1(i, K)printf("%lld\n", ans[i]);

    return 0;
}
0