結果

問題 No.1292 パタパタ三角形
ユーザー どらら
提出日時 2020-11-20 22:18:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,663 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 200,160 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-07-23 13:13:54
合計ジャッジ時間 3,559 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

void update(char c, pair<int,int>& pos, int& type, map<char,int>& ang){
  if(type == 0){
    map<int,char> chr;
    FOR(it,ang) chr[it->second] = it->first;

    if(ang[c] == 1){//left
      pos.second--;
      ang[chr[3]] = 1;
      ang[chr[2]] = 2;
      ang[chr[1]] = 3;
    }
    else if(ang[c] == 2){//right
      pos.second++;
      ang[chr[2]] = 1;
      ang[chr[1]] = 2;
      ang[chr[3]] = 3;      
    }
    else{//down
      pos.first++;
      ang[chr[1]] = 1;
      ang[chr[3]] = 2;
      ang[chr[2]] = 3;            
    }
  }else{
    map<int,char> chr;
    FOR(it,ang) chr[it->second] = it->first;
    
    if(ang[c] == 1){//left
      pos.second--;
      ang[chr[2]] = 1;
      ang[chr[1]] = 2;
      ang[chr[3]] = 3;
    }
    else if(ang[c] == 2){//up
      pos.first--;
      ang[chr[1]] = 1;
      ang[chr[3]] = 2;
      ang[chr[2]] = 3;      
    }
    else{//right
      pos.second++;
      ang[chr[3]] = 1;
      ang[chr[2]] = 2;
      ang[chr[1]] = 3;            
    }
  }

  type = 1 - type;
}


int main(){
  string S;
  cin >> S;

  map<pair<int,int>,bool> memo;
  pair<int,int> pos = make_pair(0,0);
  memo[pos] = true;
  int type = 0;
  map<char,int> ang;
  ang['a'] = 1;
  ang['b'] = 2;
  ang['c'] = 3;
  rep(i,S.size()){
    update(S[i], pos, type, ang);
    memo[pos] = true;
  }

  cout << memo.size() << endl;
  
  return 0;
}
0