結果

問題 No.1292 パタパタ三角形
ユーザー spihillspihill
提出日時 2021-01-09 16:09:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 2,607 ms
コンパイル使用メモリ 213,288 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2023-08-11 06:58:36
合計ジャッジ時間 4,477 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 33 ms
5,296 KB
testcase_08 AC 33 ms
5,232 KB
testcase_09 AC 53 ms
12,356 KB
testcase_10 AC 57 ms
12,312 KB
testcase_11 AC 56 ms
12,288 KB
testcase_12 AC 70 ms
12,928 KB
testcase_13 AC 62 ms
12,716 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 11 ms
4,380 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