結果

問題 No.606 カラフルタイル
ユーザー karinohitokarinohito
提出日時 2022-07-30 01:00:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 2,363 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 210,532 KB
実行使用メモリ 10,348 KB
最終ジャッジ日時 2023-09-27 01:36:38
合計ジャッジ時間 6,077 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 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,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 20 ms
4,536 KB
testcase_17 AC 190 ms
10,348 KB
testcase_18 AC 57 ms
9,304 KB
testcase_19 AC 51 ms
8,744 KB
testcase_20 AC 214 ms
9,120 KB
testcase_21 AC 64 ms
8,252 KB
testcase_22 AC 60 ms
8,324 KB
testcase_23 AC 77 ms
7,988 KB
testcase_24 AC 149 ms
8,224 KB
testcase_25 AC 149 ms
5,320 KB
testcase_26 AC 189 ms
10,124 KB
testcase_27 AC 191 ms
10,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vvvvb = vector<vvvb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
#define all(A) A.begin(),A.end()
#define ALL(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
using pqr = priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>;

template<class T>
bool chmax(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p < q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T>
bool chmin(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p > q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

ll gcd(ll(a), ll(b)) {
    if (b == 0)return a;
    ll c = a;
    while (a % b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

vector<ll> fact, factinv, inv;
ll mod = 998244353;
void prenCkModp(ll n) {
	fact.resize(n + 5);
	factinv.resize(n + 5);
	inv.resize(n + 5);
	fact.at(0) = fact.at(1) = 1;
	factinv.at(0) = factinv.at(1) = 1;
	inv.at(1) = 1;
	for (ll i = 2; i < n + 5; i++) {
		fact.at(i) = (fact.at(i - 1) * i) % mod;
		inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
		factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
	}

}
ll nCk(ll n, ll k) {
	if (n < k) return 0;
	return fact.at(n) * (factinv.at(k) * factinv.at(n - k) % mod) % mod;
}


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

    ll N,K,Q;
    cin>>N>>K>>Q;
    vll AN(K,0);
    vector<char> A(Q);
    vll B(Q),C(Q);
    rep(i,Q)cin>>A[i]>>B[i]>>C[i];
    ll R=N,W=N;
    set<ll> UR,UW;
    rep(i,Q){
        ll j=Q-i-1;
        if(A[j]!='R'){
            if(UR.count(B[j]))continue;
            AN[C[j]-1]+=R;
            W--;
            UR.insert(B[j]);
        }
        else{
            if(UW.count(B[j]))continue;
            AN[C[j]-1]+=W;
            R--;
            UW.insert(B[j]);
        }
    }
    ll n=N*N;
    rep(i,K-1)n-=AN[i+1];
    AN[0]=n;
    rep(i,K){
        cout<<AN[i]<<endl;
    }
}
0