結果

問題 No.1292 パタパタ三角形
コンテスト
ユーザー 🍮かんプリン
提出日時 2020-11-20 21:54:08
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,040 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,619 ms
コンパイル使用メモリ 188,640 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2026-04-03 14:25:15
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.11.20 21:54:03
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s;cin >> s;
    int n = s.size();
    set<pair<int,int>> st;
    int ans = 0;
    int now_x = 200000, now_y = 200000;
    st.insert({now_x,now_y});
    for (int i = 0; i < n; i++) {
        if (now_x % 2 == 0 && now_y % 3 == 0) {
            if (s[i] == 'a') {
                now_y++;
            }
            else if (s[i] == 'b') {
                now_x--;
            }
            else {
                now_y--;
            }
        }
        else if (now_x % 2 == 0 && now_y % 3 == 1) {
            if (s[i] == 'a') {
                now_y--;
            }
            else if (s[i] == 'b') {
                now_y++;
            }
            else {
                now_x++;
            }
        }
        else if (now_x % 2 == 0 && now_y % 3 == 2) {
            if (s[i] == 'a') {
                now_x--;
            }
            else if (s[i] == 'b') {
                now_y--;
            }
            else {
                now_y++;
            }
        }
        else if (now_x % 2 == 1 && now_y % 3 == 0) {
            if (s[i] == 'a') {
                now_y++;
            }
            else if (s[i] == 'b') {
                now_x++;
            }
            else {
                now_y--;
            }
        }
        else if (now_x % 2 == 1 && now_y % 3 == 1) {
            if (s[i] == 'a') {
                now_y--;
            }
            else if (s[i] == 'b') {
                now_y++;
            }
            else {
                now_x--;
            }
        }
        else if (now_x % 2 == 1 && now_y % 3 == 2) {
            if (s[i] == 'a') {
                now_x++;
            }
            else if (s[i] == 'b') {
                now_y--;
            }
            else {
                now_y++;
            }
        }
        st.insert({now_x,now_y});
    }
    cout << st.size() << endl;
    return 0;
}
0