結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 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,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 29 ms
5,304 KB
testcase_08 AC 29 ms
5,216 KB
testcase_09 AC 53 ms
12,336 KB
testcase_10 AC 58 ms
12,200 KB
testcase_11 AC 55 ms
12,256 KB
testcase_12 AC 60 ms
12,752 KB
testcase_13 AC 57 ms
12,692 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 7 ms
4,376 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));
  }
  cerr << "x = " << x << ", y = " << y << endl;
  cout << pos.size() << endl;
}
0