結果

問題 No.1292 パタパタ三角形
ユーザー rokahikou1rokahikou1
提出日時 2020-11-21 01:17:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 3,211 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 181,436 KB
実行使用メモリ 12,820 KB
最終ジャッジ日時 2023-09-30 20:25:23
合計ジャッジ時間 2,938 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 35 ms
5,280 KB
testcase_08 AC 34 ms
5,240 KB
testcase_09 AC 55 ms
12,440 KB
testcase_10 AC 56 ms
12,252 KB
testcase_11 AC 56 ms
12,376 KB
testcase_12 AC 60 ms
12,820 KB
testcase_13 AC 61 ms
12,764 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 11 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: メンバ関数 ‘void Triangle::operation(char)’ 内:
main.cpp:41:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   41 |         auto [dx, dy] = order;
      |              ^
main.cpp:42:19: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   42 |         for(auto &[_c, op] : ope) {
      |                   ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

struct Triangle {
    int x, y;
    map<char, pii> ope;
    const pii yp = {0, 1}, ym = {0, -1}, xp = {1, 0}, xm = {-1, 0};
    Triangle() {
        x = 0, y = 0;
        ope['a'] = {0, -1};
        ope['b'] = {0, 1};
        ope['c'] = {1, 0};
    };

    void operation(char c) {
        const pii order = ope[c];
        auto [dx, dy] = order;
        for(auto &[_c, op] : ope) {
            if((x + y) % 2 == 0) {
                if(order == yp) {
                    if(c == _c) {
                        op.first *= -1;
                        op.second *= -1;
                    } else {
                        swap(op.first, op.second);
                    }
                } else if(order == ym) {
                    if(c == _c) {
                        op.first *= -1;
                        op.second *= -1;
                    } else {
                        swap(op.first, op.second);
                        op.first *= -1;
                        op.second *= -1;
                    }
                } else {
                    if(c == _c) {
                        op.first *= -1;
                        op.second *= -1;
                    } else {
                    }
                }
            } else {
                if(order == yp) {
                    if(c == _c) {
                        op.first *= -1;
                        op.second *= -1;
                    } else {
                        swap(op.first, op.second);
                        op.first *= -1;
                        op.second *= -1;
                    }
                } else if(order == ym) {
                    if(c == _c) {
                        op.first *= -1;
                        op.second *= -1;
                    } else {
                        swap(op.first, op.second);
                    }
                } else {
                    if(c == _c) {
                        op.first *= -1;
                        op.second *= -1;
                    } else {
                    }
                }
            }
        }
        x += dx, y += dy;
    }
};

int main() {
    string S;
    cin >> S;
    int N = S.size();
    set<pii> se;
    pii state = {0, 0};
    se.insert(state);
    Triangle tri = Triangle();
    for(int i = 0; i < N; i++) {
        tri.operation(S[i]);
        se.insert({tri.x, tri.y});
    }
    cout << se.size() << endl;
}
0