結果

問題 No.1292 パタパタ三角形
ユーザー kyoprounokyoprouno
提出日時 2020-11-20 22:28:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 3,256 bytes
コンパイル時間 2,411 ms
コンパイル使用メモリ 191,564 KB
実行使用メモリ 15,880 KB
最終ジャッジ日時 2023-09-30 19:34:00
合計ジャッジ時間 3,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 36 ms
5,944 KB
testcase_08 AC 35 ms
5,852 KB
testcase_09 AC 64 ms
15,336 KB
testcase_10 AC 69 ms
15,276 KB
testcase_11 AC 69 ms
15,396 KB
testcase_12 AC 73 ms
15,880 KB
testcase_13 AC 75 ms
15,880 KB
testcase_14 AC 12 ms
4,376 KB
testcase_15 AC 12 ms
4,376 KB
testcase_16 AC 12 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}



template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    pll now;
    now.fi=0,now.se=0;
    bool up=true;
    map<ll,ll> q;
    vector<ll> p(3),buf(3);
    p[0]=0,p[1]=1,p[2]=2;
    q[0]=0,q[1]=1,q[2]=2;
    set<pll> ans;
    ans.insert({0,0});
    rep(i,n){
        ll num=s[i]-'a';
        ll v=q[num];
        if(up){
            if(v==0){
                buf[0]=p[1];
                q[buf[0]]=0;
                buf[1]=p[0];
                q[buf[1]]=1;
                buf[2]=p[2];
                q[buf[2]]=2;
                p=buf;
                now.fi-=1;
                now.se+=1;
                ans.insert(now);
            }
            if(v==1){
                buf[0]=p[0];
                q[buf[0]]=0;
                buf[1]=p[2];
                q[buf[1]]=1;
                buf[2]=p[1];
                q[buf[2]]=2;
                p=buf;
                now.fi+=1;
                now.se+=1;
                ans.insert(now);
            }
            if(v==2){
                buf[0]=p[2];
                q[buf[0]]=0;
                buf[1]=p[1];
                q[buf[1]]=1;
                buf[2]=p[0];
                q[buf[2]]=2;
                p=buf;
                now.se-=2;
                ans.insert(now);
            }
            up=false;
        }
        else{
            if(v==0){
                buf[0]=p[2];
                q[buf[0]]=0;
                buf[1]=p[1];
                q[buf[1]]=1;
                buf[2]=p[0];
                q[buf[2]]=2;
                p=buf;
                now.se+=2;
                ans.insert(now);
            }
            if(v==1){
                buf[0]=p[1];
                q[buf[0]]=0;
                buf[1]=p[0];
                q[buf[1]]=1;
                buf[2]=p[2];
                q[buf[2]]=2;
                p=buf;
                now.fi+=1;
                now.se-=1;
                ans.insert(now);
            }
            if(v==2){
                buf[0]=p[0];
                q[buf[0]]=0;
                buf[1]=p[2];
                q[buf[1]]=1;
                buf[2]=p[1];
                q[buf[2]]=2;
                p=buf;
                now.fi-=1;
                now.se-=1;
                ans.insert(now);
            }
            up=true;
        }
        
    }
    cout << ans.size() << endl;
    
    return 0;
}
0