結果
| 問題 | 
                            No.2073 Concon Substrings (Swap Version)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-09-16 22:09:32 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 34 ms / 2,000 ms | 
| コード長 | 624 bytes | 
| コンパイル時間 | 2,038 ms | 
| コンパイル使用メモリ | 198,492 KB | 
| 最終ジャッジ日時 | 2025-02-07 09:43:12 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vector<int>> cnt(3,vector<int>(3));
  rep(i,n) rep(j,3) {
    if(s[i*3+j] == 'c') cnt[j][0]++;
    if(s[i*3+j] == 'o') cnt[j][1]++;
    if(s[i*3+j] == 'n') cnt[j][2]++;
  }
  int ans = 0;
  ans += min({cnt[0][0],cnt[1][1],cnt[2][2]});
  if(ans == n) {
    cout << ans << endl;
    return 0;
  }
  ans += min({cnt[1][0],cnt[2][1],cnt[0][2]}) + min({cnt[2][0],cnt[0][1],cnt[1][2]});
  ans = min(ans,n-1);
  cout << ans << endl;
  return 0;
}