結果

問題 No.1292 パタパタ三角形
ユーザー nemutainemutai
提出日時 2023-03-29 11:00:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 174,044 KB
実行使用メモリ 16,180 KB
最終ジャッジ日時 2023-10-21 03:33:55
合計ジャッジ時間 2,882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 31 ms
6,232 KB
testcase_08 AC 31 ms
6,104 KB
testcase_09 AC 62 ms
15,636 KB
testcase_10 AC 61 ms
15,528 KB
testcase_11 AC 65 ms
15,424 KB
testcase_12 AC 67 ms
16,180 KB
testcase_13 AC 68 ms
16,180 KB
testcase_14 AC 8 ms
4,348 KB
testcase_15 AC 8 ms
4,348 KB
testcase_16 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using P = pair<ll,ll>;

int main(){
    string S;
    cin>>S;
    ll N=S.size();
    char l='b',r='c',u='a';
    ll lr=0,ud=0;
    set<P> st;
    st.insert(make_pair(0,0));
    for(int i=0;i<N;i++){
        if(S[i]==l){
            lr--;
            swap(u,r);
            swap(l,r);
            st.insert(make_pair(lr,ud));
        }else if(S[i]==r){
            lr++;
            swap(l,u);
            swap(l,r);
            st.insert(make_pair(lr,ud));
        }else{
            if((lr+ud)%2==0)ud--;
            else ud++;

            st.insert(make_pair(lr,ud));
        }
    }
    cout << st.size() << endl;
}
0