結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-01-23 12:38:54 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 53 ms / 2,000 ms | 
| コード長 | 651 bytes | 
| コンパイル時間 | 1,611 ms | 
| コンパイル使用メモリ | 79,776 KB | 
| 最終ジャッジ日時 | 2025-01-18 07:24:33 | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#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;
}
            
            
            
        