結果

問題 No.606 カラフルタイル
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-12-06 01:11:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,940 bytes
コンパイル時間 2,999 ms
コンパイル使用メモリ 92,952 KB
実行使用メモリ 14,792 KB
最終ジャッジ日時 2023-08-19 05:40:28
合計ジャッジ時間 5,851 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,440 KB
testcase_01 AC 5 ms
7,520 KB
testcase_02 AC 5 ms
7,356 KB
testcase_03 AC 4 ms
7,560 KB
testcase_04 AC 4 ms
7,436 KB
testcase_05 AC 4 ms
7,340 KB
testcase_06 AC 4 ms
7,384 KB
testcase_07 AC 4 ms
7,596 KB
testcase_08 AC 4 ms
7,348 KB
testcase_09 AC 4 ms
7,352 KB
testcase_10 AC 4 ms
7,436 KB
testcase_11 AC 5 ms
7,340 KB
testcase_12 AC 4 ms
7,368 KB
testcase_13 AC 9 ms
7,492 KB
testcase_14 AC 5 ms
7,404 KB
testcase_15 AC 5 ms
7,560 KB
testcase_16 AC 46 ms
9,812 KB
testcase_17 AC 79 ms
14,308 KB
testcase_18 AC 60 ms
14,172 KB
testcase_19 AC 59 ms
14,792 KB
testcase_20 AC 82 ms
14,132 KB
testcase_21 AC 62 ms
14,528 KB
testcase_22 AC 61 ms
14,308 KB
testcase_23 AC 68 ms
12,280 KB
testcase_24 AC 75 ms
12,160 KB
testcase_25 AC 74 ms
9,252 KB
testcase_26 AC 79 ms
14,088 KB
testcase_27 AC 79 ms
14,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dy[100100];
ll dx[100100];
ll dy1[100100];
ll dx1[100100];
ll dd[100100];

int main() {
  ll n,k,q;
  cin>>n>>k>>q;
  vector<pair<pair<ll,ll>,ll > > v;
  rep(i,0,q){
    char a;
    ll b,c;
    cin>>a>>b>>c;
    b--;c--;
    if(a=='R'){
      v.pb(mp(mp(0,b),c));
    }
    else{
      v.pb(mp(mp(1,b),c));
    }
  }
  reverse(all(v));
  clr(dy,0);
  clr(dx,0);
  clr(dy1,0);
  clr(dx1,0);
  clr(dd,0);
  vector<pair<pair<ll,ll>,ll > > v1;
  rep(i,0,v.sz){
    if(v[i].fi.fi==0){
      if(dy[v[i].fi.se]==0){
        dy[v[i].fi.se] = 1;
        v1.pb(mp(mp(0,v[i].fi.se),v[i].se));
      }
    }
    else{
      if(dx[v[i].fi.se]==0){
        dx[v[i].fi.se] = 1;
        v1.pb(mp(mp(1,v[i].fi.se),v[i].se));
      }      
    }
  }
  reverse(all(v1));
  rep(i,0,v1.sz){
    if(v1[i].fi.fi==0){
      dy1[i] = 1;
    }
    else{
      dx1[i] = 1;
    }
  }
  per(i,1,100100){
    dy1[i-1]+=dy1[i];
    dx1[i-1]+=dx1[i];
  }
  rep(i,0,v1.sz){
    if(v1[i].fi.fi==0){
      dd[v1[i].se] += (n-dx1[i]);
    }
    else{
      dd[v1[i].se] += (n-dy1[i]);
    }
  }
  ll c = 0;
  rep(i,0,k){
    c+=dd[i];
  }
  dd[0] += n*n-c;
  rep(i,0,k){
    printf("%lld\n",dd[i]);
  }
  return 0;
}
0