結果

問題 No.1292 パタパタ三角形
ユーザー SSRSSSRS
提出日時 2020-05-22 19:55:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 2,267 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 172,708 KB
実行使用メモリ 12,852 KB
最終ジャッジ日時 2023-09-18 01:30:43
合計ジャッジ時間 2,782 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 31 ms
5,296 KB
testcase_08 AC 30 ms
5,172 KB
testcase_09 AC 56 ms
12,328 KB
testcase_10 AC 62 ms
12,188 KB
testcase_11 AC 59 ms
12,340 KB
testcase_12 AC 61 ms
12,688 KB
testcase_13 AC 58 ms
12,852 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 8 ms
4,380 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();
  assert(N >= 1);
  assert(N <= 200000);
  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;
    }
    assert(S[i] == 'a' || S[i] == 'b' || S[i] == 'c');
    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