結果

問題 No.2021 Not A but B
ユーザー atjh16atjh16
提出日時 2022-08-11 21:45:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 3,488 ms
コンパイル使用メモリ 207,472 KB
実行使用メモリ 13,004 KB
最終ジャッジ日時 2023-10-22 03:29:52
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 38 ms
9,428 KB
testcase_09 AC 38 ms
9,464 KB
testcase_10 AC 39 ms
9,424 KB
testcase_11 AC 37 ms
9,212 KB
testcase_12 AC 38 ms
9,252 KB
testcase_13 AC 38 ms
9,296 KB
testcase_14 AC 37 ms
9,404 KB
testcase_15 AC 36 ms
9,328 KB
testcase_16 AC 38 ms
9,320 KB
testcase_17 AC 36 ms
9,212 KB
testcase_18 AC 38 ms
9,492 KB
testcase_19 AC 37 ms
9,464 KB
testcase_20 AC 38 ms
9,500 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 7 ms
4,348 KB
testcase_27 AC 51 ms
12,696 KB
testcase_28 AC 48 ms
12,548 KB
testcase_29 AC 52 ms
13,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n;
string s;
set<pair<int, int>> t;

int main() {    
    cin >> n >> s;
    
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'A' && s[i + 1] == 'A')
            t.insert({ i, i + 1 });
        else if (s[i] == 'A' && s[i + 1] == 'B')
            t.insert({ i, 0 });
        else if (s[i] == 'B' && s[i + 1] == 'A')
            t.insert({ i + 1, 0 });
        else
            t.insert({ -1, -1 });
    }

    cout << t.size() << endl;
}
0