結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー |
![]() |
提出日時 | 2022-09-16 21:45:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 3,465 ms |
コンパイル使用メモリ | 251,992 KB |
最終ジャッジ日時 | 2025-02-07 09:17:15 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 37 |
ソースコード
#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[(j+3-i)%3]==S[j]){ c[(j+3-i)%3]++; } } cnt[i] = 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<=3*N){ cur+=3; sum++; cc--; } } ans = max(ans,sum); } while(next_permutation(t.begin(),t.end())); cout<<ans<<endl; return 0; }