結果

問題 No.945 YKC饅頭
ユーザー ngtkanangtkana
提出日時 2020-04-14 22:17:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,323 ms / 2,000 ms
コード長 1,238 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 203,764 KB
実行使用メモリ 8,148 KB
最終ジャッジ日時 2024-04-09 18:15:00
合計ジャッジ時間 18,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 26 ms
6,944 KB
testcase_32 AC 9 ms
6,940 KB
testcase_33 AC 210 ms
6,940 KB
testcase_34 AC 499 ms
6,940 KB
testcase_35 AC 1,039 ms
7,160 KB
testcase_36 AC 289 ms
6,940 KB
testcase_37 AC 318 ms
6,940 KB
testcase_38 AC 389 ms
6,944 KB
testcase_39 AC 105 ms
6,940 KB
testcase_40 AC 98 ms
6,944 KB
testcase_41 AC 27 ms
6,940 KB
testcase_42 AC 753 ms
7,208 KB
testcase_43 AC 192 ms
6,944 KB
testcase_44 AC 737 ms
6,940 KB
testcase_45 AC 742 ms
7,704 KB
testcase_46 AC 7 ms
6,940 KB
testcase_47 AC 512 ms
6,940 KB
testcase_48 AC 53 ms
6,940 KB
testcase_49 AC 199 ms
6,944 KB
testcase_50 AC 858 ms
7,708 KB
testcase_51 AC 1,323 ms
7,968 KB
testcase_52 AC 1,321 ms
8,076 KB
testcase_53 AC 1,322 ms
8,148 KB
testcase_54 AC 1,321 ms
8,092 KB
testcase_55 AC 1,319 ms
7,972 KB
testcase_56 AC 3 ms
6,944 KB
testcase_57 AC 3 ms
6,940 KB
testcase_58 AC 47 ms
6,940 KB
testcase_59 AC 58 ms
7,132 KB
testcase_60 AC 22 ms
6,940 KB
testcase_61 AC 51 ms
6,944 KB
testcase_62 AC 49 ms
6,940 KB
testcase_63 AC 3 ms
6,944 KB
testcase_64 AC 24 ms
6,940 KB
testcase_65 AC 19 ms
6,944 KB
testcase_66 AC 18 ms
6,940 KB
testcase_67 AC 36 ms
6,944 KB
testcase_68 AC 23 ms
6,940 KB
testcase_69 AC 9 ms
6,940 KB
testcase_70 AC 10 ms
6,940 KB
testcase_71 AC 10 ms
6,944 KB
testcase_72 AC 30 ms
6,940 KB
testcase_73 AC 55 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<std::tuple<lint,lint,char>>a(m);
    for(lint i=0;i<m;i++){
        lint l,r;char c;std::cin>>l>>r>>c;l--;
        a.at(i)={l,r,c};
    }
    std::reverse(ALL(a));
    lint k=std::sqrt(n);
    std::string ans(n,'$'),lazy(n/k+1,'$');
    for(auto[l,r,c]:a){
        lint L=l/k,R=r/k;
        if(lazy.at(L)!='$')for(lint i=L*k;i<(L+1)*k;i++)ans.at(i)=lazy.at(L);
        if(lazy.at(R)!='$')for(lint i=R*k;i<(R+1)*k;i++)ans.at(i)=lazy.at(R);
        lazy.at(L)=lazy.at(R)='$';
        for(;l<r&&l%k;ans.at(l++)=c);
        for(;l<r&&r%k;ans.at(--r)=c);
        L=l/k,R=r/k;
        for(;L<R;lazy.at(L++)=c);
    }
    for(lint i=0;i<n/k;i++){
        if(lazy.at(i)=='$')continue;
        for(lint j=i*k;j<(i+1)*k;j++)ans.at(j)=lazy.at(i);
    }
    std::cout
        <<std::count(ALL(ans),'Y')
        <<' '<<std::count(ALL(ans),'K')
        <<' '<<std::count(ALL(ans),'C')
        <<'\n';
}
0