結果

問題 No.1292 パタパタ三角形
ユーザー nanophoto12nanophoto12
提出日時 2020-11-21 00:48:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,818 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 205,404 KB
実行使用メモリ 15,952 KB
最終ジャッジ日時 2023-09-30 20:22:58
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 64 ms
15,944 KB
testcase_13 AC 63 ms
15,952 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 11 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

constexpr ll INF = 1e15;

int main() {
    string s;
    cin >> s;
    set<P> p;
    p.emplace(100000, 100000);
    int n = s.size();
    P current = { 100000,100000 };
    for (int i = 0; i < n; i++) {
        char c = s[i];
        int x = current.first;
        int y = current.second;
        if (c == 'a') {
            if (y % 2 == 0) {
                if (x % 2 == 0) {
                    current = { x, y + 1 };
                }
                else {
                    current = { x, y - 1 };
                }
            }
            else {
                if (x % 2 == 0) {
                    current = { x, y - 1 };
                }
                else {
                    current = { x, y + 1 };
                }
            }
        }
        else if (c == 'b') {
            if (x % 2 == 0) {
                current = { x+1, y};
            }
            else {
                current = { x-1, y};
            }
        }
        else {
            if (x % 2 == 0) {
                current = { x - 1, y };
            }
            else {
                current = { x + 1, y };
            }
        }
        p.emplace(current);
    }
    cout << p.size() << endl;
    return 0;
}
0