結果

問題 No.945 YKC饅頭
ユーザー ttttan2ttttan2
提出日時 2019-12-08 00:10:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 3,109 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 162,560 KB
実行使用メモリ 16,360 KB
最終ジャッジ日時 2023-08-27 07:03:14
合計ジャッジ時間 11,013 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 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 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,388 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 18 ms
5,344 KB
testcase_32 AC 31 ms
8,040 KB
testcase_33 AC 81 ms
12,336 KB
testcase_34 AC 146 ms
9,896 KB
testcase_35 AC 270 ms
15,352 KB
testcase_36 AC 135 ms
7,740 KB
testcase_37 AC 130 ms
7,564 KB
testcase_38 AC 130 ms
8,140 KB
testcase_39 AC 48 ms
7,872 KB
testcase_40 AC 58 ms
12,324 KB
testcase_41 AC 32 ms
7,996 KB
testcase_42 AC 207 ms
11,212 KB
testcase_43 AC 113 ms
7,104 KB
testcase_44 AC 204 ms
14,304 KB
testcase_45 AC 221 ms
11,756 KB
testcase_46 AC 20 ms
7,716 KB
testcase_47 AC 147 ms
9,676 KB
testcase_48 AC 27 ms
4,480 KB
testcase_49 AC 73 ms
8,148 KB
testcase_50 AC 235 ms
12,040 KB
testcase_51 AC 315 ms
16,360 KB
testcase_52 AC 311 ms
16,276 KB
testcase_53 AC 310 ms
16,356 KB
testcase_54 AC 314 ms
16,104 KB
testcase_55 AC 322 ms
16,104 KB
testcase_56 AC 48 ms
12,968 KB
testcase_57 AC 48 ms
12,896 KB
testcase_58 AC 147 ms
14,452 KB
testcase_59 AC 168 ms
15,396 KB
testcase_60 AC 90 ms
12,852 KB
testcase_61 AC 155 ms
14,720 KB
testcase_62 AC 148 ms
14,540 KB
testcase_63 AC 49 ms
12,960 KB
testcase_64 AC 94 ms
12,976 KB
testcase_65 AC 84 ms
12,900 KB
testcase_66 AC 83 ms
12,924 KB
testcase_67 AC 123 ms
14,048 KB
testcase_68 AC 92 ms
13,088 KB
testcase_69 AC 61 ms
12,948 KB
testcase_70 AC 65 ms
12,920 KB
testcase_71 AC 66 ms
12,920 KB
testcase_72 AC 102 ms
13,244 KB
testcase_73 AC 160 ms
15,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
struct LST{
private:
    int n;
    vector<ll> node,lazy;
    vector<bool> flag;
public:
    LST(vector<ll> v){
        ll sz=v.size();
        n=1;while(n<sz)n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,inf);
        flag.resize(2*n-1,false);
        rep(i,0,sz)node[i+n-1]=v[i];
        rrep(i,n-2,0)node[i]=min(node[i*2+1],node[i*2+2]);
    }
    void eval(ll k,ll l,ll r){
        if(flag[k]){
            node[k]=lazy[k];
            if(r-l>1){
                lazy[2*k+1]=lazy[k];
                lazy[2*k+2]=lazy[k];
                flag[2*k+1]=flag[2*k+2]=true;
            }
            flag[k]=false;
        }
    }
    void update(ll a,ll b,ll x,ll k=0,ll l=0,ll r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(b<=l||r<=a)return;
        if(a<=l&&r<=b){
            lazy[k]=x;
            flag[k]=true;
            eval(k,l,r);
        }
        else{
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=min(node[2*k+1],node[2*k+2]);
        }
    }
    ll find(ll a,ll b,ll k=0,ll l=0,ll r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(b<=l||a>=r)return inf;
        if(a<=l&&b>=r)return node[k];
        ll m1=find(a,b,2*k+1,l,(l+r)/2);
        ll m2=find(a,b,2*k+2,(l+r)/2,r);
        return min(m1,m2);
    }
};


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;cin>>n>>m;
    LST seg(vector<ll>(n+1,inf));
    ll l[m],r[m];
    char tt[m];
    ll t[m];
    rep(i,0,m){
        cin>>l[i]>>r[i]>>tt[i];
        if(tt[i]=='Y')t[i]=1;
        else if(tt[i]=='K')t[i]=2;
        else t[i]=3;
    }
    rrep(i,m-1,0){
        seg.update(l[i],r[i]+1,t[i]);
    }
    ll cnt[3];
    fill(cnt,cnt+3,0);
    rep(i,1,n+1){
        ll e=seg.find(i,i+1);
        if(e<=3)cnt[e-1]++;
    }
    cout<<cnt[0]<<" "<<cnt[1]<<" "<<cnt[2]<<endl;
}
0