結果

問題 No.1292 パタパタ三角形
ユーザー MisterMister
提出日時 2021-01-23 12:38:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 83,876 KB
実行使用メモリ 12,812 KB
最終ジャッジ日時 2023-08-28 22:53:24
合計ジャッジ時間 2,157 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 25 ms
5,348 KB
testcase_08 AC 25 ms
5,300 KB
testcase_09 AC 47 ms
12,332 KB
testcase_10 AC 45 ms
12,316 KB
testcase_11 AC 49 ms
12,304 KB
testcase_12 AC 52 ms
12,752 KB
testcase_13 AC 54 ms
12,812 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

const vector<pair<int, int>>
    dxys{{0, -1}, {1, 0}, {-1, 0}, {0, 1}, {1, 0}, {-1, 0}};

void solve() {
    string s;
    cin >> s;

    set<pair<int, int>> ss;
    int x = 0, y = 0;
    ss.emplace(x, y);

    for (char c : s) {
        int i = (c - 'a') * 2 + x;
        if (y % 2 != 0) i += 3;

        auto [dx, dy] = dxys[(i % 6 + 6) % 6];
        x += dx, y += dy;
        ss.emplace(x, y);
    }

    cout << ss.size() << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0