結果

問題 No.1292 パタパタ三角形
ユーザー SSRSSSRS
提出日時 2020-05-22 19:35:22
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 2,171 bytes
コンパイル時間 1,465 ms
使用メモリ 12,900 KB
最終ジャッジ日時 2023-02-06 13:56:40
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
5,152 KB
testcase_01 AC 1 ms
4,900 KB
testcase_02 AC 2 ms
5,156 KB
testcase_03 AC 1 ms
4,904 KB
testcase_04 AC 2 ms
4,904 KB
testcase_05 AC 1 ms
4,904 KB
testcase_06 AC 1 ms
4,900 KB
testcase_07 AC 29 ms
5,356 KB
testcase_08 AC 28 ms
5,340 KB
testcase_09 AC 52 ms
12,500 KB
testcase_10 AC 58 ms
12,416 KB
testcase_11 AC 55 ms
12,296 KB
testcase_12 AC 62 ms
12,800 KB
testcase_13 AC 61 ms
12,900 KB
testcase_14 AC 8 ms
4,900 KB
testcase_15 AC 7 ms
4,900 KB
testcase_16 AC 7 ms
4,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  set<pair<int, int>> pos;
  int x = 0;
  int y = 0;
  pos.insert(make_pair(x, y));
  int N = S.size();
  for (int i = 0; i < N; i++){
    int X = x % 6;
    if (X < 0){
      X += 6;
    }
    int Y = y % 2;
    if (Y < 0){
      Y += 2;
    }
    if (S[i] == 'a'){
      if (Y == 0){
        if (X == 0){
          x++;
        } else if (X == 1){
          x--;
        } else if (X == 2){
          y--;
        } else if (X == 3){
          x++;
        } else if (X == 4){
          x--;
        } else if (X == 5){
          y++;
        }
      } else {
        if (X == 0){
          x++;
        } else if (X == 1){
          x--;
        } else if (X == 2){
          y++;
        } else if (X == 3){
          x++;
        } else if (X == 4){
          x--;
        } else if (X == 5){
          y--;
        }
      }
    }
    if (S[i] == 'b'){
      if (Y == 0){
        if (X == 0){
          y--;
        } else if (X == 1){
          x++;
        } else if (X == 2){
          x--;
        } else if (X == 3){
          y++;
        } else if (X == 4){
          x++;
        } else if (X == 5){
          x--;
        }
      } else {
        if (X == 0){
          y++;
        } else if (X == 1){
          x++;
        } else if (X == 2){
          x--;
        } else if (X == 3){
          y--;
        } else if (X == 4){
          x++;
        } else if (X == 5){
          x--;
        }
      }
    }
    if (S[i] == 'c'){
      if (Y == 0){
        if (X == 0){
          x--;
        } else if (X == 1){
          y++;
        } else if (X == 2){
          x++;
        } else if (X == 3){
          x--;
        } else if (X == 4){
          y--;
        } else if (X == 5){
          x++;
        }
      } else {
        if (X == 0){
          x--;
        } else if (X == 1){
          y--;
        } else if (X == 2){
          x++;
        } else if (X == 3){
          x--;
        } else if (X == 4){
          y++;
        } else if (X == 5){
          x++;
        }
      }
    }
    pos.insert(make_pair(x, y));
  }
  cout << pos.size() << endl;
}
0