結果

問題 No.1292 パタパタ三角形
ユーザー 👑 NachiaNachia
提出日時 2020-11-20 21:45:48
言語 C++17
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 206,284 KB
実行使用メモリ 15,976 KB
最終ジャッジ日時 2023-07-09 15:45:59
合計ジャッジ時間 3,264 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 33 ms
6,176 KB
testcase_08 AC 33 ms
5,776 KB
testcase_09 AC 56 ms
15,320 KB
testcase_10 AC 62 ms
15,212 KB
testcase_11 AC 60 ms
15,112 KB
testcase_12 AC 67 ms
15,976 KB
testcase_13 AC 68 ms
15,852 KB
testcase_14 AC 11 ms
4,372 KB
testcase_15 AC 11 ms
4,368 KB
testcase_16 AC 9 ms
4,372 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