結果
問題 | No.2162 Copy and Paste 2 |
ユーザー |
![]() |
提出日時 | 2022-12-13 23:11:10 |
言語 | C++17 (gcc 12.2.0 + boost 1.81.0) |
結果 |
AC
|
実行時間 | 143 ms / 7,000 ms |
コード長 | 1,298 bytes |
コンパイル時間 | 1,842 ms |
コンパイル使用メモリ | 98,756 KB |
実行使用メモリ | 7,968 KB |
最終ジャッジ日時 | 2023-04-23 08:06:39 |
合計ジャッジ時間 | 5,207 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,372 KB |
testcase_01 | AC | 2 ms
4,372 KB |
testcase_02 | AC | 2 ms
4,368 KB |
testcase_03 | AC | 2 ms
4,368 KB |
testcase_04 | AC | 1 ms
4,368 KB |
testcase_05 | AC | 2 ms
4,372 KB |
testcase_06 | AC | 33 ms
7,748 KB |
testcase_07 | AC | 35 ms
7,780 KB |
testcase_08 | AC | 44 ms
7,756 KB |
testcase_09 | AC | 112 ms
7,676 KB |
testcase_10 | AC | 123 ms
7,640 KB |
testcase_11 | AC | 118 ms
7,636 KB |
testcase_12 | AC | 143 ms
7,628 KB |
testcase_13 | AC | 130 ms
7,636 KB |
testcase_14 | AC | 58 ms
7,752 KB |
testcase_15 | AC | 66 ms
7,628 KB |
testcase_16 | AC | 67 ms
7,652 KB |
testcase_17 | AC | 36 ms
7,668 KB |
testcase_18 | AC | 57 ms
7,628 KB |
testcase_19 | AC | 50 ms
7,684 KB |
testcase_20 | AC | 56 ms
7,968 KB |
testcase_21 | AC | 42 ms
7,776 KB |
testcase_22 | AC | 54 ms
7,640 KB |
testcase_23 | AC | 26 ms
7,680 KB |
testcase_24 | AC | 47 ms
7,716 KB |
testcase_25 | AC | 47 ms
7,632 KB |
testcase_26 | AC | 54 ms
7,628 KB |
testcase_27 | AC | 47 ms
7,632 KB |
testcase_28 | AC | 52 ms
7,648 KB |
ソースコード
#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;