結果

問題 No.1292 パタパタ三角形
ユーザー どららどらら
提出日時 2020-11-20 22:18:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,663 bytes
コンパイル時間 2,073 ms
コンパイル使用メモリ 198,756 KB
実行使用メモリ 16,008 KB
最終ジャッジ日時 2023-09-30 19:27:14
合計ジャッジ時間 3,566 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 59 ms
6,000 KB
testcase_08 AC 58 ms
5,876 KB
testcase_09 AC 87 ms
15,512 KB
testcase_10 AC 91 ms
15,348 KB
testcase_11 AC 89 ms
15,188 KB
testcase_12 AC 104 ms
16,008 KB
testcase_13 AC 97 ms
16,004 KB
testcase_14 AC 36 ms
4,380 KB
testcase_15 AC 36 ms
4,380 KB
testcase_16 AC 37 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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