結果

問題 No.2162 Copy and Paste 2
ユーザー hotman78hotman78
提出日時 2022-12-13 13:54:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,809 bytes
コンパイル時間 4,089 ms
コンパイル使用メモリ 250,868 KB
実行使用メモリ 26,636 KB
最終ジャッジ日時 2024-04-24 23:55:43
合計ジャッジ時間 16,722 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 98 ms
16,916 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 162 ms
16,580 KB
testcase_10 AC 144 ms
16,504 KB
testcase_11 WA -
testcase_12 AC 244 ms
18,508 KB
testcase_13 AC 485 ms
21,268 KB
testcase_14 AC 198 ms
17,020 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 775 ms
22,288 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 126 ms
22,220 KB
testcase_24 AC 1,036 ms
26,528 KB
testcase_25 AC 1,388 ms
26,636 KB
testcase_26 AC 1,108 ms
23,436 KB
testcase_27 AC 1,061 ms
26,588 KB
testcase_28 AC 779 ms
19,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/string>
#include<atcoder/segtree>
using namespace std;
using namespace atcoder;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;

using lint=long long;
#define rep(i,n) for(int i=0;i<int(n);++i)

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    segtree<int, op, e> seg(n+1);
    pbds<int> st;
    vector<vector<int>>v(n+1);
    auto z=z_algorithm(s);
    for(int i=0;i<n;++i){if(z[i]!=0)st.insert(i);}
    for(int i=0;i<n;++i){
        // cerr<<z[i]<<endl;
        v[z[i]].emplace_back(i);
    }

    for(int i=2;i<n+1;++i){
        // cerr<<"i:"<<i<<endl;
        for(auto e:v[i-1]){
            st.erase(e);
        }
        // for(auto e:st){
        //     cerr<<e<<endl;
        // }
        int now=i,cnt=0;
        int fst=seg.prod(0,now+1);
        while(1){
            ++cnt;
            int itr=st.order_of_key(now);
            if(itr==st.size())break;
            int to=*st.find_by_order(itr)+i;
            if(to>n)break;
            // cerr<<fst<<" "<<to<<endl;
            seg.set(to,fst+cnt*(i-1)-1);
            now=to;
        }
    }
    cout<<n-seg.all_prod()<<endl;
}
0