結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー pockynypockyny
提出日時 2022-09-18 04:16:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,100 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 77,504 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-23 18:01:58
合計ジャッジ時間 26,373 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 3 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2,720 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 2,237 ms
4,380 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 437 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 418 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>

using namespace std;
int dp[2][50010];
int main(){
    int i,j,k,n,a,b; cin >> n >> a >> b;
    string s; cin >> s;
    for(i=0;i<n;i++){
        for(j=0;j<2;j++) dp[j][i] = -1;
    }
    dp[0][0] = 0;
    string t;
    for(i=0;i<n;i++){
        if(i + 2<n && s.substr(i,3)=="con"){
           i += 2;
           t.push_back('y'); 
        }else{
            t.push_back('x');
        }
    }
    vector<pair<char,int>> v;
    for(i=0;i<t.size();i++){
        if(v.size()==0 || v.back().first!=t[i]) v.push_back({t[i],1});
        else v.back().second++;
    }
    int mx = n/3;
    for(i=0;i<v.size();i++){
        if(v[i].first=='x') continue;
        for(j=0;j<=mx;j++){
            for(k=0;k<=min(v[i].second/a,mx - j);k++){
                dp[1][j + k] = max(dp[1][j + k],dp[0][j] + (v[i].second - a*k)/b);
            }
        }
        swap(dp[0],dp[1]);
    }
    int ans = 0;
    for(j=0;j<=mx;j++){
        if(dp[0][j]==j - 1) ans = max(ans,2*j - 1);
        else if(dp[0][j]>=j) ans = max(ans,2*j);
    }
    cout << ans << "\n";
}
0