結果

問題 No.606 カラフルタイル
ユーザー ei1333333ei1333333
提出日時 2017-12-06 12:54:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 198,268 KB
実行使用メモリ 5,968 KB
最終ジャッジ日時 2023-08-19 09:38:22
合計ジャッジ時間 4,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,964 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 2 ms
5,172 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 34 ms
5,192 KB
testcase_17 AC 170 ms
5,508 KB
testcase_18 AC 44 ms
5,660 KB
testcase_19 AC 42 ms
5,404 KB
testcase_20 AC 169 ms
5,832 KB
testcase_21 AC 46 ms
5,780 KB
testcase_22 AC 46 ms
5,780 KB
testcase_23 AC 67 ms
5,740 KB
testcase_24 AC 129 ms
5,752 KB
testcase_25 AC 169 ms
5,968 KB
testcase_26 AC 173 ms
5,812 KB
testcase_27 AC 171 ms
5,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int main()
{
  int N, K, Q;
  char A[100000];
  int B[100000], C[100000];
  int row[100000], rowlazy = 0;
  int col[100000], collazy = 0;
  int64 ans[100000] = {};

  cin >> N >> K >> Q;
  for(int i = 0; i < Q; i++) {
    cin >> A[i] >> B[i] >> C[i];
    --B[i], --C[i];
  }


  for(int i = 0; i < N; i++) {
    row[i] = col[i] = N;
  }
  for(int i = Q - 1; i >= 0; i--) {
    if(A[i] == 'R') {
      if(row[B[i]] - rowlazy > 0) {
        ans[C[i]] += row[B[i]] - rowlazy;
        row[B[i]] = 0;
        ++collazy;
      }
    } else {
      if(col[B[i]] - collazy > 0) {
        ans[C[i]] += col[B[i]] - collazy;
        col[B[i]] = 0;
        ++rowlazy;
      }
    }
  }

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

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


}
0