結果

問題 No.1292 パタパタ三角形
ユーザー milanis48663220milanis48663220
提出日時 2020-11-20 22:06:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 908 ms
コンパイル使用メモリ 98,220 KB
実行使用メモリ 12,940 KB
最終ジャッジ日時 2023-09-30 19:18:54
合計ジャッジ時間 2,026 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 24 ms
5,264 KB
testcase_08 AC 24 ms
5,256 KB
testcase_09 AC 51 ms
12,308 KB
testcase_10 AC 50 ms
12,364 KB
testcase_11 AC 52 ms
12,380 KB
testcase_12 AC 54 ms
12,940 KB
testcase_13 AC 56 ms
12,872 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,376 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