結果
| 問題 | No.2076 Concon Substrings (ConVersion) |
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2022-09-16 22:03:17 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 604 ms / 5,000 ms |
| コード長 | 1,386 bytes |
| コンパイル時間 | 2,976 ms |
| コンパイル使用メモリ | 93,364 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 00:38:27 |
| 合計ジャッジ時間 | 7,123 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <atcoder/modint>
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++)
using Modint = atcoder::static_modint<998244353>;
int main(){
int N,A,B; cin >> N >> A >> B;
string S; cin >> S;
vector<int> ConCon = {0};
while(S.size() >= 3){
if(S.substr(S.size() - 3) == "con"){
S.resize(S.size() - 3);
ConCon.back()++;
continue;
}
if(ConCon.back() != 0) ConCon.push_back(0);
S.pop_back();
}
if(ConCon.back() == 0) ConCon.pop_back();
vector<int> Q(N/3/A+1, -1001001001);
Q[0] = 0;
for(int s : ConCon){
vector<int> bV;
for(int a=0; a*A<=s; a++) bV.push_back((s-a*A)/B);
for(int q=Q.size()-1; q>=0; q--){
int tmp = -1001001001;
for(int a=min((int)bV.size()-1,q); a>=0; a--) tmp = max(tmp, Q[q-a] + bV[a]);
Q[q] = tmp;
}
}
int ans = 0;
rep(i,Q.size()) if(Q[i] >= 0) ans = max(ans, min(i*2,Q[i]*2+1));
cout << ans << '\n';
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia