結果

問題 No.2162 Copy and Paste 2
ユーザー 👑 NachiaNachia
提出日時 2022-12-13 23:11:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 7,000 ms
コード長 1,298 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 112,972 KB
実行使用メモリ 7,864 KB
最終ジャッジ日時 2024-04-27 04:23:09
合計ジャッジ時間 4,177 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
純コード判定待ち
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 36 ms
7,860 KB
testcase_07 AC 37 ms
7,860 KB
testcase_08 AC 47 ms
7,856 KB
testcase_09 AC 113 ms
7,852 KB
testcase_10 AC 125 ms
7,856 KB
testcase_11 AC 120 ms
7,860 KB
testcase_12 AC 146 ms
7,732 KB
testcase_13 AC 133 ms
7,660 KB
testcase_14 AC 58 ms
7,860 KB
testcase_15 AC 68 ms
7,848 KB
testcase_16 AC 70 ms
7,860 KB
testcase_17 AC 38 ms
7,860 KB
testcase_18 AC 60 ms
7,732 KB
testcase_19 AC 53 ms
7,860 KB
testcase_20 AC 61 ms
7,864 KB
testcase_21 AC 44 ms
7,864 KB
testcase_22 AC 57 ms
7,736 KB
testcase_23 AC 28 ms
7,856 KB
testcase_24 AC 49 ms
7,732 KB
testcase_25 AC 48 ms
7,860 KB
testcase_26 AC 55 ms
7,732 KB
testcase_27 AC 49 ms
7,860 KB
testcase_28 AC 53 ms
7,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <atcoder/modint>
#include <atcoder/string>
#include <atcoder/segtree>

using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;


namespace RMQ{
    using S = int;
    S op(S l, S r){ return max(l, r); }
    S e(){ return -1; }
    using Segtree = atcoder::segtree<S, op, e>;
}


int main(){
    string S; cin >> S;
    auto Z = atcoder::z_algorithm(S);
    int n = S.size();

    RMQ::Segtree segtree(atcoder::z_algorithm(S));
    
    vector<int> dp(n+1);
    rep(i,n+1) dp[i] = i;

    for(int x=1; x<=n; x++){
        dp[x] = min(dp[x], dp[x-1] + 1);
        int p = x, t = dp[x] + 1;
        while(p < n){
            int nx = segtree.max_right(p, [x](int v){ return v<x; });
            if(nx >= n) break;
            t += nx - p + 1;
            p = nx + x;
            dp[p] = min(dp[p], t);
        }
    }

    cout << dp[n] << '\n';
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0