結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー んんんんんん
提出日時 2022-12-25 14:48:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,095 bytes
コンパイル時間 2,001 ms
コンパイル使用メモリ 202,032 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-29 20:26:22
合計ジャッジ時間 4,275 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 18 ms
5,376 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 15 ms
5,376 KB
testcase_10 AC 23 ms
5,376 KB
testcase_11 AC 23 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 7 ms
5,376 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 13 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 17 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 12 ms
5,376 KB
testcase_26 AC 17 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 15 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int A[3];

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < 3*N; i++) {
        if (i%3 == 0) {
            if (S[i] == 'c') A[0]++;
        } else if (i%3 == 1) {
            if (S[i] == 'o') A[1]++;
        } else {
            if (S[i] == 'n') A[2]++;
        }
    }
    ans += min(A[0], min(A[1], A[2]));
    for (int i = 0; i < 3; i++) A[i] = 0;
    
    for (int i = 0; i < 3*N; i++) {
        if (i%3 == 0) {
            if (S[i] == 'n') A[0]++;
        } else if (i%3 == 1) {
            if (S[i] == 'c') A[1]++;
        } else {
            if (S[i] == 'o') A[2]++;
        }
    }
    ans += min(min(N-1, A[0]), min(A[1], A[2]));
    for (int i = 0; i < 3; i++) A[i] = 0;
    
    for (int i = 0; i < 3*N; i++) {
        if (i%3 == 0) {
            if (S[i] == 'o') A[0]++;
        } else if (i%3 == 1) {
            if (S[i] == 'n') A[1]++;
        } else {
            if (S[i] == 'c') A[2]++;
        }
    }
    ans += min(min(N-1, A[0]), min(A[1], A[2]));

    cout << ans << endl;
}
0