結果
| 問題 |
No.2073 Concon Substrings (Swap Version)
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-09-16 21:40:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 824 bytes |
| コンパイル時間 | 4,680 ms |
| コンパイル使用メモリ | 252,016 KB |
| 最終ジャッジ日時 | 2025-02-07 09:10:30 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 17 WA * 20 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001
int main(){
int N;
cin>>N;
string S;
cin>>S;
string s = "con";
vector<int> cnt(3,0);
int ans = 0;
rep(i,3){
vector<int> c(3,0);
rep(j,S.size()){
if(s[(i+j)%3]==S[j]){
c[(i+j)%3]++;
}
}
cnt[(3-i)%3] = min({c[0],c[1],c[2]});
}
vector<int> t(3);
rep(i,3)t[i] = i;
do{
int cur = 0;
int sum = 0;
rep(i,3){
while(cur%3!=t[i])cur++;
int cc = cnt[t[i]];
while(cc!=0 && cur<=3*N){
cur+=3;
sum++;
cc--;
}
}
ans = max(ans,sum);
}
while(next_permutation(t.begin(),t.end()));
cout<<ans<<endl;
return 0;
}
沙耶花