結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  m_tsubasa | 
| 提出日時 | 2020-11-20 21:33:23 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 60 ms / 2,000 ms | 
| コード長 | 733 bytes | 
| コンパイル時間 | 2,071 ms | 
| コンパイル使用メモリ | 199,872 KB | 
| 最終ジャッジ日時 | 2025-01-16 02:07:22 | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
string s;
set<P> st;
int solve();
int main() {
  cin >> s;
  cout << solve() << endl;
  return 0;
}
int solve() {
  int n = s.size(), x = 0, y = 0;
  string t = "abc";
  st.insert(P(0, 0));
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      if (s[i] == t[0])
        ++y;
      else if (s[i] == t[1])
        ++x, swap(t[0], t[1]), swap(t[0], t[2]);
      else
        --y, swap(t[0], t[1]), swap(t[1], t[2]);
    } else {
      if (s[i] == t[0])
        --y;
      else if (s[i] == t[1])
        ++y, swap(t[1], t[2]), swap(t[0], t[1]);
      else
        --x, swap(t[0], t[2]), swap(t[0], t[1]);
    }
    st.insert(P(x, y));
  }
  return st.size();
}
            
            
            
        