結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2020-11-20 21:45:48 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 70 ms / 2,000 ms | 
| コード長 | 912 bytes | 
| コンパイル時間 | 2,225 ms | 
| コンパイル使用メモリ | 199,716 KB | 
| 最終ジャッジ日時 | 2025-01-16 02:15:05 | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  string S; cin>>S;
  set<pair<pair<int,int>,int>> G;
  pair<pair<int,int>,int> p = {{0,0},0};
  G.insert(p);
  string X = "abc";
  auto rotR = [&X]()->void{
    X = string({X[2],X[0],X[1]});
  };
  auto rotL = [&X]()->void{
    X = string({X[1],X[2],X[0]});
  };
  for(char c:S){
    int i = X.find(c);
    if(i==0){
      if(p.second){
        rotR();
      }
      else{
        rotR();
        p.first.first--;
      }
    }
    if(i==1){
      if(p.second){
        rotL();
        p.first.first++;
      }
      else{
        rotL();
      }
    }
    if(i==2){
      if(p.second){
        p.first.second++;
      }
      else{
        p.first.second--;
      }
    }
    p.second = 1 - p.second;
    G.insert(p);
  }
  cout<<G.size()<<endl;
  return 0;
}
            
            
            
        