結果

問題 No.1292 パタパタ三角形
ユーザー 👑 NachiaNachia
提出日時 2020-11-20 21:45:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 206,612 KB
実行使用メモリ 15,908 KB
最終ジャッジ日時 2023-09-30 19:06:02
合計ジャッジ時間 3,188 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 34 ms
5,976 KB
testcase_08 AC 33 ms
5,784 KB
testcase_09 AC 54 ms
15,312 KB
testcase_10 AC 58 ms
15,208 KB
testcase_11 AC 57 ms
15,156 KB
testcase_12 AC 65 ms
15,908 KB
testcase_13 AC 67 ms
15,908 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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