結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-02-08 23:22:18 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 79 ms / 2,000 ms | 
| コード長 | 1,001 bytes | 
| コンパイル時間 | 1,888 ms | 
| コンパイル使用メモリ | 203,000 KB | 
| 最終ジャッジ日時 | 2025-01-18 16:29:39 | 
| ジャッジサーバーID (参考情報) | judge3 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
class point {
  double x;
  double y;
public:
  point(double x, double y) {
    this->x = x;
    this->y = y;
  }
  point() {
    this->x = 0;
    this->y = 0;
  }
  
  point operator+(const point &p) const {
    return point(x + p.x, y + p.y);
  }
  point operator-(const point &p) const {
    return point(x - p.x, y - p.y);
  }
  bool operator<(const point &p) const {
    if (this->x != p.x)
      return this->x < p.x;
    return this->y < p.y;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  tuple<point, point, point> cur(point(0, 0.5), point(0, 0), point(1, 0));
  set<tuple<point, point, point> > t;
  t.insert(cur);
  
  for (char c: s) {
    point A, B, C;
    tie(A, B, C) = cur;
    if (c == 'a')
      A = B + C - A;
    else if (c == 'b')
      B = C + A - B;
    else
      C = A + B - C;
    cur = tuple(A, B, C);
    t.insert(cur);
  }
  
  cout << t.size() << endl;
  
  return 0;
}
            
            
            
        