結果
| 問題 | No.2073 Concon Substrings (Swap Version) | 
| コンテスト | |
| ユーザー |  AngrySadEight | 
| 提出日時 | 2022-08-23 12:21:12 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 19 ms / 2,000 ms | 
| コード長 | 723 bytes | 
| コンパイル時間 | 828 ms | 
| コンパイル使用メモリ | 72,968 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-21 17:54:21 | 
| 合計ジャッジ時間 | 2,975 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<int>> cnt(3, vector<int>(3, 0));
    for (int i = 0; i < 3 * N; i++){
        if (S[i] == 'c') cnt[0][i % 3]++;
        else if (S[i] == 'o') cnt[1][i % 3]++;
        else if (S[i] == 'n') cnt[2][i % 3]++;
    }
    vector<int> min_sum(3);
    int ans = 0;
    for (int i = 0; i < 3; i++){
        min_sum[i] = min(cnt[0][i], min(cnt[1][(i + 1) % 3], cnt[2][(i + 2) % 3]));
        ans += min_sum[i];
    }
    if (ans == N){
        if (min_sum[0] == N) cout << N << endl;
        else cout << N - 1 << endl;
    }
    else{
        cout << ans << endl;
    }
}
            
            
            
        