結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  milanis48663220 | 
| 提出日時 | 2020-11-20 22:06:17 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 55 ms / 2,000 ms | 
| コード長 | 820 bytes | 
| コンパイル時間 | 1,072 ms | 
| コンパイル使用メモリ | 98,600 KB | 
| 実行使用メモリ | 12,928 KB | 
| 最終ジャッジ日時 | 2024-07-23 13:05:09 | 
| 合計ジャッジ時間 | 1,920 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#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;
}
            
            
            
        