結果

問題 No.1292 パタパタ三角形
ユーザー IlagIlag
提出日時 2020-11-21 09:24:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,354 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 171,032 KB
実行使用メモリ 12,844 KB
最終ジャッジ日時 2023-09-30 21:39:06
合計ジャッジ時間 2,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 24 ms
5,404 KB
testcase_08 AC 24 ms
5,156 KB
testcase_09 AC 45 ms
12,380 KB
testcase_10 AC 46 ms
12,332 KB
testcase_11 AC 45 ms
12,140 KB
testcase_12 AC 55 ms
12,808 KB
testcase_13 AC 55 ms
12,844 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1001001001;
const long long MOD = /**/1000000007;//*/998244353;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    set<pair<int,int>> st;
    int y=0,x=0,rev=0;
    st.insert(make_pair(y,x));
    char bot='c',top='d',le='a',ri='b';
    for(int i=0;i<s.size();i++){
        if(rev==1){
            if(s[i]==top){
                bot=top;
                top='d';
                y--;
            }else if(s[i]==le){
                char t=le;
                bot=ri;
                le=top;
                ri=t;
                x--;
            }else{
                char t=ri;
                bot=le;
                ri=top;
                le=t;
                x++;
            }
        }else{
            if(s[i]==bot){
                top=bot;
                bot='d';
                y++;
            }else if(s[i]==le){
                char t=le;
                top=ri;
                le=bot;
                ri=t;
                x--;
            }else{
                char t=ri;
                top=le;
                ri=bot;
                le=t;
                x++;
            }
        }
        rev=1-rev;
        st.insert(make_pair(y,x));
    }
    cout<<st.size()<<endl;
}
0