結果

問題 No.1292 パタパタ三角形
ユーザー spihillspihill
提出日時 2021-01-09 16:09:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 2,493 ms
コンパイル使用メモリ 216,316 KB
実行使用メモリ 12,916 KB
最終ジャッジ日時 2024-04-28 23:37:09
合計ジャッジ時間 3,921 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,948 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 36 ms
6,944 KB
testcase_08 AC 35 ms
6,940 KB
testcase_09 AC 55 ms
12,508 KB
testcase_10 AC 61 ms
12,416 KB
testcase_11 AC 58 ms
12,348 KB
testcase_12 AC 73 ms
12,916 KB
testcase_13 AC 64 ms
12,908 KB
testcase_14 AC 9 ms
6,948 KB
testcase_15 AC 13 ms
6,944 KB
testcase_16 AC 13 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    map<char, pair<int, int>> m;
    m['a'] = {-1, 0};
    m['b'] = {0, -1};
    m['c'] = {0, 1};
    int r = 0, c = 0;
    set<pair<int ,int>> st;
    st.insert({r, c});
    for (int i = 0, sg = -1; i < (int) s.size(); i++, sg = -sg) {
        auto [dr, dc] = m[s[i]];
        r += dr; c += dc;
        st.insert({r, c});
        m[s[i]] = {-dr, -dc};
        if (dr == 0) {
            for (char c = 'a'; c <= 'c'; c++) {
                if (m[c].first) m[c] = {dr, dc};
                else if (c != s[i]) m[c] = {sg, 0};
            }
        }
    }
    cout << st.size() << endl;
}
0