結果

問題 No.2021 Not A but B
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-07-29 22:05:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 448 bytes
コンパイル時間 1,832 ms
コンパイル使用メモリ 204,372 KB
実行使用メモリ 12,752 KB
最終ジャッジ日時 2023-09-26 21:03:02
合計ジャッジ時間 3,942 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 42 ms
9,380 KB
testcase_09 AC 41 ms
9,208 KB
testcase_10 AC 42 ms
9,220 KB
testcase_11 AC 39 ms
8,960 KB
testcase_12 AC 42 ms
9,048 KB
testcase_13 AC 40 ms
9,060 KB
testcase_14 AC 40 ms
9,156 KB
testcase_15 AC 42 ms
9,224 KB
testcase_16 AC 41 ms
9,144 KB
testcase_17 AC 40 ms
8,956 KB
testcase_18 AC 44 ms
9,236 KB
testcase_19 AC 43 ms
9,296 KB
testcase_20 AC 43 ms
9,244 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 10 ms
4,380 KB
testcase_27 AC 58 ms
12,496 KB
testcase_28 AC 55 ms
12,308 KB
testcase_29 AC 56 ms
12,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    string s;
    cin >> s;
    set<pair<int, int>> st;
    for (int i = 0; i < N - 1; i ++) {
        int a = -1, b = -1;
        if (s[i] == 'A') {
            a = i;
        }
        if (s[i + 1] == 'A') {
            b = i + 1;
        }
        if (a == -1) {
            swap(a, b);
        }
        st.emplace(a, b);
    }
    cout << st.size() << endl;
}
0