結果

問題 No.1292 パタパタ三角形
ユーザー milanis48663220milanis48663220
提出日時 2020-11-20 22:06:17
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 738 ms
使用メモリ 12,840 KB
最終ジャッジ日時 2023-02-23 18:24:24
合計ジャッジ時間 2,080 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
6,256 KB
testcase_01 AC 1 ms
6,192 KB
testcase_02 AC 1 ms
6,192 KB
testcase_03 AC 2 ms
6,180 KB
testcase_04 AC 1 ms
6,192 KB
testcase_05 AC 1 ms
6,260 KB
testcase_06 AC 1 ms
6,180 KB
testcase_07 AC 24 ms
6,252 KB
testcase_08 AC 23 ms
6,172 KB
testcase_09 AC 48 ms
12,460 KB
testcase_10 AC 46 ms
12,288 KB
testcase_11 AC 48 ms
12,276 KB
testcase_12 AC 52 ms
12,764 KB
testcase_13 AC 57 ms
12,840 KB
testcase_14 AC 4 ms
6,260 KB
testcase_15 AC 3 ms
6,192 KB
testcase_16 AC 4 ms
6,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int rem3(int x){
    return ((x%3)+3)%3;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s; cin >> s;
    int x = 0, y = 0;
    set<P> st;
    st.insert(P(0, 0));
    for(char c : s){
        int m = c-'a';
        if(rem3(m-x) == 0){
            if((x+y)%2 == 0){
                y--;
            }else{
                y++;
            }
        }else if(rem3(m-x) == 1){
            x--;
        }else{
            x++;
        }
        st.insert(P(x, y));
        // cout << x << ' ' << y << endl;
    }
    cout << st.size() << endl;
}
0