結果

問題 No.1292 パタパタ三角形
コンテスト
ユーザー 👑 Nachia
提出日時 2020-11-20 21:45:48
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 912 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,387 ms
コンパイル使用メモリ 218,712 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2026-06-15 06:11:34
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}

0