結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー んんんんんん
提出日時 2022-12-25 14:59:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 201,580 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 20:33:50
合計ジャッジ時間 3,889 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 19 ms
5,376 KB
testcase_06 AC 19 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 13 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 20 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 18 ms
5,376 KB
testcase_20 AC 14 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 18 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 12 ms
5,376 KB
testcase_26 AC 18 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]++;
        }
    }
    int ans1 = min(A[0], min(A[1], A[2]));
    ans += ans1;
    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]++;
        }
    }
    int ans2 = min(A[0], min(A[1], A[2]));
    ans += ans2;
    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]++;
        }
    }
    int ans3 = min(A[0], min(A[1], A[2]));
    ans += ans3;

    if (ans2 > 0 && ans3 > 0) ans -= max(0, 2 - (N-ans));
    else if (ans2 > 0 || ans3 > 0) ans -= max(0, 1 - (N-ans));

    cout << ans << endl;
}
0